Lock opacity for sticky windows

This commit is contained in:
John Mertz 2024-03-08 12:03:16 -07:00
parent 2be287ef9f
commit 6ef42310f1
1 changed files with 9 additions and 2 deletions

View File

@ -19,6 +19,8 @@ def on_window_focus(opacity, ipc, event):
return return
global prev_focused global prev_focused
global prev_workspace global prev_workspace
# Refresh previous window in case it changed while in focus
prev_focused = ipc.get_tree().find_by_id(prev_focused.id)
focused_workspace = ipc.get_tree().find_focused() focused_workspace = ipc.get_tree().find_focused()
@ -30,7 +32,7 @@ def on_window_focus(opacity, ipc, event):
if focused.id != prev_focused.id: # https://github.com/swaywm/sway/issues/2859 if focused.id != prev_focused.id: # https://github.com/swaywm/sway/issues/2859
focused.command("opacity 1") focused.command("opacity 1")
if workspace == prev_workspace: if workspace == prev_workspace and not prev_focused.sticky:
prev_focused.command("opacity " + opacity) prev_focused.command("opacity " + opacity)
prev_focused = focused prev_focused = focused
prev_workspace = workspace prev_workspace = workspace
@ -81,6 +83,9 @@ def remove_opacity(ipc):
def set_all(ipc,opacity): def set_all(ipc,opacity):
for window in ipc.get_tree(): for window in ipc.get_tree():
if prev_focused.sticky:
window.command("opacity 1")
else:
window.command("opacity " + opacity) window.command("opacity " + opacity)
flag = os.environ["HOME"]+"/.spool/sway-hidden" flag = os.environ["HOME"]+"/.spool/sway-hidden"
@ -115,6 +120,8 @@ if __name__ == "__main__":
for window in ipc.get_tree(): for window in ipc.get_tree():
if window.focused: if window.focused:
prev_focused = window prev_focused = window
elif window.sticky:
continue
else: else:
window.command("opacity " + args.opacity) window.command("opacity " + args.opacity)
for sig in [signal.SIGINT, signal.SIGTERM]: for sig in [signal.SIGINT, signal.SIGTERM]: