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

Add custom position and resizing #24

Open
wants to merge 2 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
Binary file modified MiroWindowsManager.spoon.zip
Binary file not shown.
12 changes: 11 additions & 1 deletion MiroWindowsManager.spoon/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
" * left: for the left action (usually {hyper, \"left\"})",
" * fullscreen: for the full-screen action (e.g. {hyper, \"f\"})",
" * nextscreen: for multi monitor the next screen action (e.g. {hyper, \"n\"})",
" * custom: for custom position/resize actions (e.g. custom = {",
" * {hyper, \"1\", 0, 0, 375, 667, \"iPhone 6/6s (375 x 667)\"},",
" * {hyper, \"2\", 0, 0, 1024, 768, \"1024 x 768\"},",
" * {hyper, \"3\", 0, 0, 1280, 720, \"1280 x 720\"},",
" * }})",
"",
"A configuration example can be:",
"```",
Expand All @@ -114,6 +119,11 @@
" left = {hyper, \"left\"},",
" fullscreen = {hyper, \"f\"}",
" nextscreen = {hyper, \"n\"}",
" custom: for custom position/resize actions (e.g. custom = {",
" {hyper, \"1\", 0, 0, 375, 667, \"iPhone 6/6s (375 x 667)\"},",
" {hyper, \"2\", 0, 0, 1024, 768, \"1024 x 768\"},",
" {hyper, \"3\", 0, 0, 1280, 720, \"1280 x 720\"},",
" }})",
"})",
"```"
],
Expand Down Expand Up @@ -243,4 +253,4 @@
],
"name" : "MiroWindowsManager"
}
]
]
16 changes: 16 additions & 0 deletions MiroWindowsManager.spoon/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ function obj:_fullDimension(dim)
end
end

function obj:_positionAndResizeScreen(x, y, w, h, label)
if hs.window.focusedWindow() then
local win = hs.window.frontmostWindow()
hs.alert(label)
win:setFrame({x=x, y=y, w=w, h=h})
end
end

--- MiroWindowsManager:bindHotkeys()
--- Method
--- Binds hotkeys for Miro's Windows Manager
Expand Down Expand Up @@ -240,6 +248,14 @@ function obj:bindHotkeys(mapping)
self:_moveNextScreenStep()
end)

if mapping.custom then
for i,v in pairs(mapping.custom) do
hs.hotkey.bind(v[1], v[2], function ()
self:_positionAndResizeScreen(v[3], v[4], v[5], v[6], v[7])
end)
end
end

end

function obj:init()
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ spoon.MiroWindowsManager:bindHotkeys({
down = {hyper, "down"},
left = {hyper, "left"},
fullscreen = {hyper, "f"},
nextscreen = {hyper, "n"}
nextscreen = {hyper, "n"},
custom = {
{hyper, "1", 0, 0, 375, 667, "iPhone 6/6s (375 x 667)"},
{hyper, "2", 0, 0, 1024, 768, "1024 x 768"},
{hyper, "3", 0, 0, 1280, 720, "1280 x 720"}
}
})
```

Expand Down