Last active
February 24, 2024 14:36
-
-
Save zhiyelee/6770b07abd0b92ae5a9c09525e355d30 to your computer and use it in GitHub Desktop.
Hammerspoon: move cursor between screens
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
--- 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