Avoid crashing the script on initial startup

This commit is contained in:
DrPandemic 2021-01-02 14:16:33 -05:00
parent 19261c8cbe
commit 4587bf4d6b
No known key found for this signature in database
GPG key ID: 7B26A8060A4CD8C1

View file

@ -37,7 +37,11 @@ def on_window(ipc: i3ipc.connection.Connection, event: i3ipc.events.WindowEvent)
if __name__ == "__main__":
ipc = i3ipc.Connection()
prev_focused = ipc.get_tree().find_focused().id
focused = ipc.get_tree().find_focused()
if focused:
prev_focused = focused.id
else:
prev_focused = None
windows = {}
ipc.on("window", on_window)