Replies: 3 comments 1 reply
-
Put something together now but not sure how correct this is: function resizeAndCenterWinByPerc(perc)
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
local w = max.w*perc
local h = max.h*perc
f.w = w
f.h = h
win:setFrame(f, 0)
f.x = max.w/2 - w/2
f.y = max.h/2 - h/2
nf = screen:localToAbsolute(f)
win:move(nf, screen, true, 0)
end
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "C", function()
resizeAndCenterWinByPerc(0.8)
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "V", function()
resizeAndCenterWinByPerc(0.6)
end) |
Beta Was this translation helpful? Give feedback.
1 reply
-
macos has this feature built-in... fn+ctrl+c |
Beta Was this translation helpful? Give feedback.
0 replies
-
I think the easiest solution is to think of it as two different operations, each with its own function:
That will handle any number of external monitors. If an operation is common, create a small function that calls these two functions one after the other.
will return the screen where the window is. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am not sure if I'm doing something wrong but I am trying to center the window and it works fine on the main monitor but doesn't work for any other monitors.
Here's there relevant code:
Can anyone point me in the right direction on how I can make this work accross different monitors?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions