Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the screen to be moved to a different monitor in a reverse direction #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions MiroWindowsManager.spoon/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,17 @@ function obj:_nextFullScreenStep()
end
end

function obj:_moveNextScreenStep()
function obj:_moveScreenStep(direction)
if hs.window.focusedWindow() then
local win = hs.window.frontmostWindow()
local id = win:id()
local screen = win:screen()

win:move(win:frame():toUnitRect(screen:frame()), screen:next(), true, 0)

if (direction == "next") then
win:move(win:frame():toUnitRect(screen:frame()), screen:next(), true)
elseif (direction == "previous") then
win:move(win:frame():toUnitRect(screen:frame()), screen:previous(), true)
end
end
end

Expand Down Expand Up @@ -237,7 +241,11 @@ function obj:bindHotkeys(mapping)
end)

hs.hotkey.bind(mapping.nextscreen[1], mapping.nextscreen[2], function ()
self:_moveNextScreenStep()
self:_moveScreenStep("next")
end)

hs.hotkey.bind(mapping.previousscreen[1], mapping.previousscreen[2], function ()
self:_moveScreenStep("previous")
end)

end
Expand All @@ -249,4 +257,4 @@ function obj:init()
hs.grid.MARGINY = 0
end

return obj
return obj
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ spoon.MiroWindowsManager:bindHotkeys({
down = {hyper, "down"},
left = {hyper, "left"},
fullscreen = {hyper, "f"},
nextscreen = {hyper, "n"}
nextscreen = {hyper, "n"},
previousscreen = {hyper, "p"}
})
```

Expand Down Expand Up @@ -75,9 +76,10 @@ As the other shortcuts, `hyper` + `f` can be pressed multiple times to obtain a

### Move to other display

- `hyper` + `n`: move to other monitor.
- `hyper` + `n`: move to next monitor.
- `hyper` + `p`: move to previous monitor.

Hitting that shortcut multiple times will rotate between the number of monitors
Hitting the shortcuts multiple times will rotate between the number of monitors

## Animations

Expand Down