From cc54ef2495e380201ba70757dca22f82e60e5495 Mon Sep 17 00:00:00 2001 From: Vladimir-csp <4061903+Vladimir-csp@users.noreply.github.com> Date: Wed, 21 Feb 2024 11:35:00 +0300 Subject: [PATCH] Parse argument first --- layout-per-window.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/layout-per-window.py b/layout-per-window.py index 5c271c8..c21d71f 100755 --- a/layout-per-window.py +++ b/layout-per-window.py @@ -52,14 +52,6 @@ def on_window(ipc: i3ipc.connection.Connection, event: i3ipc.events.WindowEvent) if __name__ == "__main__": - ipc = i3ipc.Connection() - focused = ipc.get_tree().find_focused() - if focused: - prev_focused = focused.id - else: - prev_focused = None - windows = {} - if len(sys.argv) == 2: if sys.argv[1].isnumeric(): default_layout = int(sys.argv[1]) @@ -72,5 +64,13 @@ def on_window(ipc: i3ipc.connection.Connection, event: i3ipc.events.WindowEvent) else: default_layout = None + ipc = i3ipc.Connection() + focused = ipc.get_tree().find_focused() + if focused: + prev_focused = focused.id + else: + prev_focused = None + windows = {} + ipc.on("window", on_window) ipc.main()