mirror of
https://github.com/RGBCube/ncc
synced 2025-07-27 18:17:44 +00:00
paperwm: overhaul space change binds
This commit is contained in:
parent
3e466fcaf0
commit
7f2a57a24d
1 changed files with 25 additions and 7 deletions
|
@ -106,7 +106,7 @@ in {
|
||||||
window:close()
|
window:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
local spaceChange = function(offset)
|
local currentSpaceIndex = function()
|
||||||
local current_space = hs.spaces.activeSpaceOnScreen()
|
local current_space = hs.spaces.activeSpaceOnScreen()
|
||||||
local spaces = hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]
|
local spaces = hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]
|
||||||
|
|
||||||
|
@ -118,6 +118,13 @@ in {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return current_index
|
||||||
|
end
|
||||||
|
|
||||||
|
local changeSpaceBy = function(offset)
|
||||||
|
local current_index = currentSpaceIndex()
|
||||||
|
local spaces = hs.spaces.allSpaces()[hs.screen.mainScreen():getUUID()]
|
||||||
|
|
||||||
local next_index = current_index + offset
|
local next_index = current_index + offset
|
||||||
if next_index > #spaces then
|
if next_index > #spaces then
|
||||||
next_index = 1
|
next_index = 1
|
||||||
|
@ -125,11 +132,22 @@ in {
|
||||||
next_index = #spaces
|
next_index = #spaces
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if next_index == current_index then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local next_space = spaces[next_index]
|
local next_space = spaces[next_index]
|
||||||
|
|
||||||
hs.spaces.gotoSpace(next_space)
|
hs.spaces.gotoSpace(next_space)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local gotoSpace = function(index)
|
||||||
|
local current_index = currentSpaceIndex()
|
||||||
|
local change_by = index - current_index
|
||||||
|
|
||||||
|
changeSpaceBy(change_by)
|
||||||
|
end
|
||||||
|
|
||||||
do -- HOTKEYS
|
do -- HOTKEYS
|
||||||
local super = { "cmd", "ctrl" }
|
local super = { "cmd", "ctrl" }
|
||||||
local super_alt = { "cmd", "ctrl", "alt" }
|
local super_alt = { "cmd", "ctrl", "alt" }
|
||||||
|
@ -161,12 +179,12 @@ in {
|
||||||
hs.hotkey.bind(super_alt, "f", PaperWM.actions.full_width)
|
hs.hotkey.bind(super_alt, "f", PaperWM.actions.full_width)
|
||||||
|
|
||||||
-- CYCLE SPACES -- SUPER[ + SHIFT FOR REVERSE] + TAB
|
-- CYCLE SPACES -- SUPER[ + SHIFT FOR REVERSE] + TAB
|
||||||
hs.hotkey.bind(super, "tab", function() spaceChange(1) end)
|
hs.hotkey.bind(super, "tab", function() changeSpaceBy(1) end)
|
||||||
hs.hotkey.bind(super_shift, "tab", function() spaceChange(-1) end)
|
hs.hotkey.bind(super_shift, "tab", function() changeSpaceBy(-1) end)
|
||||||
|
|
||||||
for index = 1, 9 do
|
for index = 1, 9 do
|
||||||
-- GO TO SPACE -- SUPER + NUMBER
|
-- GO TO SPACE -- SUPER + NUMBER
|
||||||
hs.hotkey.bind(super, tostring(index), PaperWM.actions["switch_space_" .. index])
|
hs.hotkey.bind(super, tostring(index), function() gotoSpace(index) end)
|
||||||
|
|
||||||
-- MOVE WINDOW TO SPACE -- SUPER + SHIFT + NUMBER
|
-- MOVE WINDOW TO SPACE -- SUPER + SHIFT + NUMBER
|
||||||
hs.hotkey.bind(super_shift, tostring(index), PaperWM.actions["move_window_" .. index])
|
hs.hotkey.bind(super_shift, tostring(index), PaperWM.actions["move_window_" .. index])
|
||||||
|
@ -217,9 +235,9 @@ in {
|
||||||
threshold = math.huge -- only trigger once per swipe
|
threshold = math.huge -- only trigger once per swipe
|
||||||
|
|
||||||
if direction == "up" then
|
if direction == "up" then
|
||||||
spaceChange(1)
|
changeSpaceBy(1)
|
||||||
elseif direction == "down" then
|
elseif direction == "down" then
|
||||||
spaceChange(-1)
|
changeSpaceBy(-1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -249,7 +267,7 @@ in {
|
||||||
local button = hs.menubar.new()
|
local button = hs.menubar.new()
|
||||||
button:setTitle(hs.styledtext.new(title, attributes))
|
button:setTitle(hs.styledtext.new(title, attributes))
|
||||||
button:setClickCallback(function()
|
button:setClickCallback(function()
|
||||||
hs.spaces.gotoSpace(space)
|
gotoSpace(space)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
table.insert(space_buttons, button)
|
table.insert(space_buttons, button)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue