From 93c786f9e3d77398a6c2123482ed623303b54109 Mon Sep 17 00:00:00 2001 From: John Mertz Date: Fri, 8 Mar 2024 12:45:19 -0700 Subject: [PATCH] Don't skip opacity changes if prev_focused was killed --- sway/sway-transparency.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sway/sway-transparency.py b/sway/sway-transparency.py index 421b53f..8d57777 100755 --- a/sway/sway-transparency.py +++ b/sway/sway-transparency.py @@ -20,7 +20,8 @@ def on_window_focus(opacity, ipc, event): global prev_focused global prev_workspace # Refresh previous window in case it changed while in focus - prev_focused = ipc.get_tree().find_by_id(prev_focused.id) + if prev_focused: + prev_focused = ipc.get_tree().find_by_id(prev_focused.id) focused_workspace = ipc.get_tree().find_focused() @@ -30,9 +31,9 @@ def on_window_focus(opacity, ipc, event): focused = event.container workspace = focused_workspace.workspace().num - if prev_focused and focused.id != prev_focused.id: # https://github.com/swaywm/sway/issues/2859 + if prev_focused == None or focused.id != prev_focused.id: # https://github.com/swaywm/sway/issues/2859 focused.command("opacity 1") - if workspace == prev_workspace and not prev_focused.sticky: + if prev_focused and workspace == prev_workspace and not prev_focused.sticky: prev_focused.command("opacity " + opacity) prev_focused = focused prev_workspace = workspace