nix-configuration/home-manager/hammerspoon/window-move.lua
2025-05-28 11:12:33 +02: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("0F6BDB5B-840D-40BE-AAC9-B467A78E057A")
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("B5A65BB6-E73E-4C3D-977C-33C86798AA5A")
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("0F6BDB5B-840D-40BE-AAC9-B467A78E057A")
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("B5A65BB6-E73E-4C3D-977C-33C86798AA5A")
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()