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