nix-configuration/home-manager/hammerspoon/window-move.lua
2025-02-03 10:06:26 +01:00

69 lines
1.4 KiB
Lua

windowMove = function()
-- move window to next screen
hs.hotkey.bind({ "ctrl", "alt", "cmd" }, "N", function()
local win = hs.window.focusedWindow()
win:moveToScreen(win:screen():next())
end)
local fullscreen = function(win)
local screen = win:screen()
local cell = hs.grid.get(win, screen)
cell.x = 0
cell.y = 0
cell.w = 24
cell.h = 24
hs.grid.set(win, cell, screen)
end
local getScreenById = function(id)
for _, screen in ipairs(hs.screen.allScreens()) do
if screen:getUUID() == id then
return screen
end
end
return nil
end
hs.hotkey.bind({ "ctrl", "alt", "cmd" }, "pad1", function()
-- DELL S2722DGM
local screen = getScreenById("0F6BDB5B-840D-40BE-AAC9-B467A78E057A")
if screen == nil then
return
end
local win = hs.window.focusedWindow()
win:moveToScreen(screen)
fullscreen(win)
end)
hs.hotkey.bind({ "ctrl", "alt", "cmd" }, "pad2", function()
-- DELL S2721DGF
local screen = getScreenById("D3142823-261D-46EF-B9C2-5181C7FE2CA5")
if screen == nil then
return
end
local win = hs.window.focusedWindow()
win:moveToScreen(screen)
fullscreen(win)
end)
hs.hotkey.bind({ "ctrl", "alt", "cmd" }, "pad3", function()
-- AV Receiver
local screen = getScreenById("B5A65BB6-E73E-4C3D-977C-33C86798AA5A")
if screen == nil then
return
end
local win = hs.window.focusedWindow()
win:moveToScreen(screen)
fullscreen(win)
end)
end
windowMove()