diff options
-rw-r--r-- | autotiling/main.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/autotiling/main.py b/autotiling/main.py index 5a8547e..896034b 100644 --- a/autotiling/main.py +++ b/autotiling/main.py @@ -13,6 +13,7 @@ License: GPL3 Dependencies: python-i3ipc>=2.0.1 (i3ipc-python) """ import argparse +import os import sys from functools import partial @@ -24,6 +25,26 @@ except ImportError: __version__ = "unknown" +def temp_dir(): + if os.getenv("TMPDIR"): + return os.getenv("TMPDIR") + elif os.getenv("TEMP"): + return os.getenv("TEMP") + elif os.getenv("TMP"): + return os.getenv("TMP") + + return "/tmp" + + +def save_string(string, file): + try: + file = open(file, "wt") + file.write(string) + file.close() + except Exception as e: + print(e) + + def switch_splitting(i3, e, debug, workspaces): try: con = i3.get_tree().find_focused() @@ -85,6 +106,10 @@ def main(): if args.debug and args.workspaces: print("autotiling is only active on workspaces:", ','.join(args.workspaces)) + + # For use w/ nwg-panel + if args.workspaces: + save_string(','.join(args.workspaces), os.path.join(temp_dir(), "autotiling")) handler = partial(switch_splitting, debug=args.debug, workspaces=args.workspaces) i3 = Connection() |