From 0bc648708fc9c1ab4680af4485b355ac600846af Mon Sep 17 00:00:00 2001 From: Scott Moreau Date: Sat, 25 Nov 2023 16:01:17 -0700 Subject: [PATCH] trailfocus.py: Check parent instead of state for toplevels --- ipc-scripts/trailfocus.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ipc-scripts/trailfocus.py b/ipc-scripts/trailfocus.py index 1fbd6c0..1ce243e 100755 --- a/ipc-scripts/trailfocus.py +++ b/ipc-scripts/trailfocus.py @@ -20,11 +20,12 @@ def output_realized(output): def sort_views(): try: views = commands_sock.list_views() + outputs.clear() timestamps = [] for v in views: if v["app-id"] == "$unfocus panel" or v["layer"] == "background": continue - if v["state"] != {} and v["state"]["minimized"]: + if "parent" in v and v["state"]["minimized"]: continue timestamps.append(v["last-focus-timestamp"]) if not output_realized(v["output"]): @@ -35,7 +36,7 @@ def sort_views(): for v in views: if v["output"] != o or v["app-id"] == "$unfocus panel" or v["layer"] == "background": continue - if v["state"] != {} and v["state"]["minimized"]: + if "parent" in v and v["state"]["minimized"]: continue i += 1 o_step = 0.2 / i @@ -50,7 +51,7 @@ def sort_views(): continue if v["output"] != o or v["app-id"] == "$unfocus panel" or v["layer"] == "background": break - if v["state"] != {} and v["state"]["minimized"]: + if "parent" in v and v["state"]["minimized"]: break o_value += o_step b_value += b_step @@ -59,7 +60,8 @@ def sort_views(): commands_sock.set_view_brightness(v["id"], b_value, 1000) commands_sock.set_view_saturation(v["id"], s_value, 1000) break - except: + except Exception as error: + print("An exception occurred:", error) pass sort_views()