Skip to content

Commit

Permalink
trailfocus.py: Handle multiple outputs (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
soreau authored Nov 17, 2023
1 parent d3febdf commit 3f1ad7b
Showing 1 changed file with 38 additions and 19 deletions.
57 changes: 38 additions & 19 deletions ipc-scripts/trailfocus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 3f1ad7b

Please sign in to comment.