From 76c1be057ec142d9e74aca945810efa9458b36d9 Mon Sep 17 00:00:00 2001 From: Scott Moreau Date: Thu, 16 Nov 2023 23:55:33 -0700 Subject: [PATCH] trailfocus.py: Handle multiple outputs --- ipc-scripts/trailfocus.py | 57 ++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/ipc-scripts/trailfocus.py b/ipc-scripts/trailfocus.py index 6ce0e5f..c04f146 100755 --- a/ipc-scripts/trailfocus.py +++ b/ipc-scripts/trailfocus.py @@ -9,31 +9,50 @@ commands_sock = WayfireSocket(addr) commands_sock.watch() +outputs = [] + +def output_realized(output): + for o in outputs: + if output == o: + return True + return False + def sort_views(): - i = 0 for v in commands_sock.list_views(): if v["app-id"] == "$unfocus panel" or v["layer"] == "background": continue if v["state"] != {} and v["state"]["minimized"]: continue - i += 1 - o_step = 0.2 / i - b_step = 0.5 / i - s_step = 1.0 / i - o_value = 0.8 - b_value = 0.5 - s_value = 0.0 - for v in commands_sock.list_views()[::-1]: - if v["app-id"] == "$unfocus panel" or v["layer"] == "background": - continue - if v["state"] != {} and v["state"]["minimized"]: - continue - o_value += o_step - b_value += b_step - s_value += s_step - commands_sock.set_view_opacity(v["id"], o_value, 1000) - commands_sock.set_view_brightness(v["id"], b_value, 1000) - commands_sock.set_view_saturation(v["id"], s_value, 1000) + if not output_realized(v["output"]): + outputs.append(v["output"]) + for o in outputs: + try: + i = 0 + for v in commands_sock.list_views(): + if v["output"] != o or v["app-id"] == "$unfocus panel" or v["layer"] == "background": + continue + if v["state"] != {} and v["state"]["minimized"]: + continue + i += 1 + o_step = 0.2 / i + b_step = 0.5 / i + s_step = 1.0 / i + o_value = 0.8 + b_value = 0.5 + s_value = 0.0 + for v in commands_sock.list_views()[::-1]: + if v["output"] != o or v["app-id"] == "$unfocus panel" or v["layer"] == "background": + continue + if v["state"] != {} and v["state"]["minimized"]: + continue + o_value += o_step + b_value += b_step + s_value += s_step + commands_sock.set_view_opacity(v["id"], o_value, 1000) + commands_sock.set_view_brightness(v["id"], b_value, 1000) + commands_sock.set_view_saturation(v["id"], s_value, 1000) + except: + pass sort_views()