From fd6c28f6aa96392b5ef5edde9c31a1ec52329c6b Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 7 Nov 2019 22:12:55 +0100 Subject: window_layout: Fix error when saved window not found Saw this error when a saved window ID doesn't exist: 2019-11-07 16:25:03: 16:25:03 ERROR: LuaSkin: hs.screen.watcher callback: $HOME/.hammerspoon/window_layout.lua:39: attempt to index a nil value stack traceback: $HOME/.hammerspoon/window_layout.lua:39: in upvalue 'window_positions_restore' $HOME/.hammerspoon/window_layout.lua:52: in function This could be when a saved window was closed, in which case we don't care that its position can't be restored. --- window_layout.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'window_layout.lua') diff --git a/window_layout.lua b/window_layout.lua index f8d201a..e32f37e 100644 --- a/window_layout.lua +++ b/window_layout.lua @@ -36,7 +36,11 @@ local function window_positions_restore() local screen = hs.screen.primaryScreen():id() for id, frame in pairs(window_positions[screen]) do - hs.window.get(id):setFrame(frame) + local window = hs.window.get(id) + + if window then + window:setFrame(frame) + end end end -- cgit v1.2.3