diff options
author | piotr <nwg.piotr@gmail.com> | 2021-02-16 03:25:17 +0100 |
---|---|---|
committer | piotr <nwg.piotr@gmail.com> | 2021-02-16 03:25:17 +0100 |
commit | 23c402a44c2682a5a8779433315ca2371da16c73 (patch) | |
tree | 7583fb6c8bbc355d9ddf782761b5a65ac5a6422e | |
parent | 2167750b25610ccc250a554b45e2c14590c59034 (diff) | |
download | autotiling-23c402a44c2682a5a8779433315ca2371da16c73.tar.gz |
Save args.workspaces to /tmp for use with nwg-panel
-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() |