Skip to content

Instantly share code, notes, and snippets.

@zhiyelee
Last active February 24, 2024 14:36
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 zhiyelee/6770b07abd0b92ae5a9c09525e355d30 to your computer and use it in GitHub Desktop.
Save zhiyelee/6770b07abd0b92ae5a9c09525e355d30 to your computer and use it in GitHub Desktop.
Hammerspoon: move cursor between screens
--- start move cursor bewteen screens
function move_cursor(direction)
return function()
local screen = hs.mouse.getCurrentScreen()
local nextScreen
if direction == "right" then
nextScreen = screen:next()
else
nextScreen = screen:previous()
end
local rect = nextScreen:fullFrame()
-- get the center of the rect
local center = hs.geometry.rect(rect).center
hs.mouse.setAbsolutePosition(center)
end
end
hs.hotkey.bind({"alt", "shift"}, "Right", move_cursor('right'))
hs.hotkey.bind({"alt", "shift"}, "Left", move_cursor('left'))
-- end move cursor between screens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment