nix-configuration/home-manager/hammerspoon/window-move.lua
2025-12-29 12:23:03 +01:00

127 lines
2.6 KiB
Lua

windowMove = function()
local grid = hs.grid
local screen = hs.screen
local timer = hs.timer
local window = hs.window
-- move window to next screen
hs.hotkey.bind({ "ctrl", "alt", "cmd" }, "N", function()
local win = window.focusedWindow()
win:moveToScreen(win:screen():next())
end)
local fullscreen = function(win)
local scr = win:screen()
local cell = grid.get(win, scr)
cell.x = 0
cell.y = 0
cell.w = 24
cell.h = 24
grid.set(win, cell, scr)
end
local getScreenById = function(id)
for _, scr in ipairs(screen.allScreens()) do
if scr:getUUID() == id then
return scr
end
end
return nil
end
hs.hotkey.bind({ "ctrl", "alt", "cmd" }, "pad1", function()
-- DELL S2722DGM
local scr = getScreenById("394ACDEE-CA25-43C4-A533-D4EDF4A897AF")
if scr == nil then
return
end
local win = window.focusedWindow()
win:moveToScreen(scr)
timer.doAfter(1, function()
fullscreen(win)
end)
end)
hs.hotkey.bind({ "ctrl", "alt", "cmd" }, "pad2", function()
-- DELL S2721DGF
local scr = getScreenById("D3142823-261D-46EF-B9C2-5181C7FE2CA5")
if scr == nil then
return
end
local win = window.focusedWindow()
win:moveToScreen(scr)
timer.doAfter(1, function()
fullscreen(win)
end)
end)
hs.hotkey.bind({ "ctrl", "alt", "cmd" }, "pad3", function()
-- AV Receiver
local scr = getScreenById("B5845603-D54C-44B8-9B55-96F7E5F50646")
if scr == nil then
return
end
local win = window.focusedWindow()
win:moveToScreen(scr)
timer.doAfter(1, function()
fullscreen(win)
end)
end)
hs.hotkey.bind({ "ctrl", "alt", "cmd", "shift" }, "pad1", function()
-- DELL S2722DGM
local scr = getScreenById("394ACDEE-CA25-43C4-A533-D4EDF4A897AF")
if scr == nil then
return
end
for _, win in ipairs(window.focusedWindow():application():allWindows()) do
win:moveToScreen(scr)
timer.doAfter(1, function()
fullscreen(win)
end)
end
end)
hs.hotkey.bind({ "ctrl", "alt", "cmd", "shift" }, "pad2", function()
-- DELL S2721DGF
local scr = getScreenById("D3142823-261D-46EF-B9C2-5181C7FE2CA5")
if scr == nil then
return
end
for _, win in ipairs(window.focusedWindow():application():allWindows()) do
win:moveToScreen(scr)
timer.doAfter(1, function()
fullscreen(win)
end)
end
end)
hs.hotkey.bind({ "ctrl", "alt", "cmd", "shift" }, "pad3", function()
-- AV Receiver
local scr = getScreenById("B5845603-D54C-44B8-9B55-96F7E5F50646")
if scr == nil then
return
end
for _, win in ipairs(window.focusedWindow():application():allWindows()) do
win:moveToScreen(scr)
timer.doAfter(1, function()
fullscreen(win)
end)
end
end)
end
windowMove()