Skip to content

Instantly share code, notes, and snippets.

@bgreenlee
Created January 24, 2018 04:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgreenlee/77f1fbeb673eb674ed6065b189dec4d3 to your computer and use it in GitHub Desktop.
Save bgreenlee/77f1fbeb673eb674ed6065b189dec4d3 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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