-
-
Save NanonaN/1ed6e181ffe5d834ea2dfd8ab841df0b to your computer and use it in GitHub Desktop.
Hammerspoon script for saving windows layout on macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frames = {} | |
hs.hotkey.bind({ "cmd", "alt" }, "S", function() | |
frames = {} | |
local windows = hs.window.allWindows() | |
for i, _ in ipairs(windows) do | |
local window = windows[i] | |
frames[window:id()] = window:frame() | |
end | |
hs.alert.show("Saved") | |
end) | |
hs.hotkey.bind({ "cmd", "alt", }, "R", function() | |
local windows = hs.window.allWindows() | |
for i, _ in ipairs(windows) do | |
local window = windows[i] | |
local saved_frame = frames[window:id()] | |
if saved_frame ~= nil then | |
window:setFrame(saved_frame) | |
end | |
end | |
hs.alert.show("Restored") | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment