Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hammerspoon function to move off-screen windows onto the main screen
-- Rescue Windows
-- Move any windows that are off-screen onto the main screen
function rescueWindows()
local screen = hs.screen.mainScreen()
local screenFrame = screen:fullFrame()
local wins = hs.window.visibleWindows()
for i,win in ipairs(wins) do
local frame = win:frame()
if not frame:inside(screenFrame) then
win:moveToScreen(screen, true, true)
end
end
end
return rescueWindows
@bgreenlee

This comment has been minimized.

Copy link
Owner Author

@bgreenlee bgreenlee commented Jan 24, 2018

In init.lua:

rescueWindows = require "rescuewindows"
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "R", rescueWindows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment