aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Miller <nwg.piotr@gmail.com>2021-01-08 16:05:40 +0100
committerGitHub <noreply@github.com>2021-01-08 16:05:40 +0100
commit0cebc23c88c6d089d87d98918971a8c5a54a663d (patch)
tree5cda8ccdcfead21da61061138f6f026a3be54f3c
parentccc1d594615399e2c2092645682a9684d8057037 (diff)
parent08d4a0303f9b3a7cd230f0493d711af0a48c0025 (diff)
downloadautotiling-0cebc23c88c6d089d87d98918971a8c5a54a663d.tar.gz
Merge pull request #22 from riscie/master
adds --workspace cli argument to restrict autotiling to certain workspaces
-rw-r--r--autotiling/main.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/autotiling/main.py b/autotiling/main.py
index 3f6969e..5c20215 100644
--- a/autotiling/main.py
+++ b/autotiling/main.py
@@ -26,10 +26,10 @@ except ImportError:
-def switch_splitting(i3, e, debug):
+def switch_splitting(i3, e, debug, workspaces):
try:
con = i3.get_tree().find_focused()
- if con:
+ if con and not workspaces or (str(con.workspace().num) in workspaces):
if con.floating:
# We're on i3: on sway it would be None
# May be 'auto_on' or 'user_on'
@@ -65,7 +65,7 @@ def switch_splitting(i3, e, debug):
)
elif debug:
- print("Debug: No focused container found", file=sys.stderr)
+ print("Debug: No focused container found or autotiling on workspace turned off", file=sys.stderr)
except Exception as e:
print("Error: {}".format(e), file=sys.stderr)
@@ -83,9 +83,21 @@ def main():
version="%(prog)s {}, Python {}".format(__version__, sys.version),
help="display version information",
)
+ parser.add_argument(
+ "--workspaces",
+ "-w",
+ help="Restricts autotiling to certain workspaces. Example: autotiling --workspaces 8 9",
+ nargs="*",
+ type=str,
+ default=[],
+ )
args = parser.parse_args()
- handler = partial(switch_splitting, debug=args.debug)
+
+ if args.debug and args.workspaces:
+ print("autotiling is only active on workspaces:", ','.join(args.workspaces))
+
+ handler = partial(switch_splitting, debug=args.debug, workspaces=args.workspaces)
i3 = Connection()
i3.on(Event.WINDOW_FOCUS, handler)
i3.main()