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

Added support to place windows in thirds horizontally on the screen. #76

Open
wants to merge 2 commits into
base: main
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ Use <kbd>control</kbd> + <kbd>s</kbd> to turn on Window Layout Mode. Then, use a
- Use <kbd>←</kbd> to send window to the monitor on the left (if there is one)
- Use <kbd>→</kbd> to send window to the monitor on the right (if there is one)
- Use <kbd>control</kbd> + <kbd>s</kbd> to exit Window Layout Mode without moving any windows
- Use <kbd>q</kbd> to send window to left and take 33% of screen
- Use <kbd>w</kbd> to send window to middle and take 33% of screen
- Use <kbd>e</kbd> to send window to right and take 33% of screen
- Use <kbd>a</kbd> to send window to left and take 66% of screen
- Use <kbd>d</kbd> to send window to right and take 66% of screen

[<img src="https://cloud.githubusercontent.com/assets/2988/22397114/715cc12e-e538-11e6-9dcd-b3447af0d9dd.png" alt="Window Layout Mode Keybindings (1)" width="400"/>](https://cloud.githubusercontent.com/assets/2988/22397114/715cc12e-e538-11e6-9dcd-b3447af0d9dd.png) [<img src="https://cloud.githubusercontent.com/assets/2988/22397111/45672fe6-e538-11e6-905d-5b0234e290bb.png" alt="Window Layout Mode Keybindings (2)" width="400"/>](https://cloud.githubusercontent.com/assets/2988/22397111/45672fe6-e538-11e6-905d-5b0234e290bb.png)

Expand Down
5 changes: 5 additions & 0 deletions hammerspoon/windows-bindings-defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,10 @@ return {
{ {}, 'n', 'nextScreen' },
{ {}, 'right', 'moveOneScreenEast' },
{ {}, 'left', 'moveOneScreenWest' },
{ {}, 'q', 'left33' },
{ {}, 'w', 'middle33' },
{ {}, 'e', 'right33' },
{ {}, 'a', 'left66' },
{ {}, 'd', 'right66' },
}
}
85 changes: 85 additions & 0 deletions hammerspoon/windows.lua
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,91 @@ function window.right60(win)
win:setFrame(f)
end

-- +-----------------+
-- | | | |
-- |HERE | | |
-- | | | |
-- +-----------------+
function window.left33(win)
local f = win:frame()
local screen = win:screen()
local max = screen:frame()

f.x = max.x
f.y = max.y
f.w = max.w * 0.333333
f.h = max.h
win:setFrame(f)
end

-- +-----------------+
-- | | | |
-- | |HERE | |
-- | | | |
-- +-----------------+
function window.middle33(win)
local f = win:frame()
local screen = win:screen()
local max = screen:frame()

f.x = max.x + (max.w * 0.333333)
f.y = max.y
f.w = max.w * 0.333333
f.h = max.h
win:setFrame(f)
end

-- +-----------------+
-- | | | |
-- | | |HERE |
-- | | | |
-- +-----------------+
function window.right33(win)
local f = win:frame()
local screen = win:screen()
local max = screen:frame()

f.x = max.x + (max.w * 0.666666)
f.y = max.y
f.w = max.w * 0.333333
f.h = max.h
win:setFrame(f)
end

-- +-----------------+
-- | | |
-- | HERE | |
-- | | |
-- +-----------------+
function window.left66(win)
local f = win:frame()
local screen = win:screen()
local max = screen:frame()

f.x = max.x
f.y = max.y
f.w = max.w * 0.666666
f.h = max.h
win:setFrame(f)
end

-- +-----------------+
-- | | |
-- | | HERE |
-- | | |
-- +-----------------+
function window.right66(win)
local f = win:frame()
local screen = win:screen()
local max = screen:frame()

f.x = max.x + (max.w * 0.333333)
f.y = max.y
f.w = max.w * 0.666666
f.h = max.h
win:setFrame(f)
end

function window.nextScreen(win)
local currentScreen = win:screen()
local allScreens = hs.screen.allScreens()
Expand Down