aboutsummaryrefslogtreecommitdiffstats
path: root/window_layout.lua
diff options
context:
space:
mode:
authorTeddy Wing2019-11-07 22:12:55 +0100
committerTeddy Wing2019-11-07 22:12:55 +0100
commitfd6c28f6aa96392b5ef5edde9c31a1ec52329c6b (patch)
tree8571f06e57d8b1257eeccf5ea60251c43454a077 /window_layout.lua
parentab8d4c637552a1aa9db480fd4f7f60c8a47b80c3 (diff)
downloaddothammerspoon-fd6c28f6aa96392b5ef5edde9c31a1ec52329c6b.tar.bz2
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 </$HOME/.hammerspoon/window_layout.lua:51> This could be when a saved window was closed, in which case we don't care that its position can't be restored.
Diffstat (limited to 'window_layout.lua')
-rw-r--r--window_layout.lua6
1 files changed, 5 insertions, 1 deletions
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