Prepare window switching for all spaces
This commit is contained in:
parent
f8807df81c
commit
a9f26cfd6b
@ -26,6 +26,10 @@ return (function()
|
||||
screen = "B5A65BB6-E73E-4C3D-977C-33C86798AA5A",
|
||||
fullscreen = true,
|
||||
},
|
||||
Notes = {
|
||||
desktop = 2,
|
||||
screen = "B5A65BB6-E73E-4C3D-977C-33C86798AA5A"
|
||||
},
|
||||
Spotify = {
|
||||
desktop = 3,
|
||||
screen = "B5A65BB6-E73E-4C3D-977C-33C86798AA5A",
|
||||
@ -63,24 +67,46 @@ return (function()
|
||||
|
||||
local currentSpaces = spaces.allSpaces()
|
||||
|
||||
for _, v in pairs(window.list()) do
|
||||
local def = appScreenMap[v.kCGWindowOwnerName]
|
||||
local win = window.get(v.kCGWindowNumber)
|
||||
if def ~= nil and win ~= nil then
|
||||
local spaceMap = {}
|
||||
for _, screenSpaces in pairs(currentSpaces) do
|
||||
for _, space in ipairs(screenSpaces) do
|
||||
spaceMap[space] = true
|
||||
end
|
||||
end
|
||||
|
||||
local spaceIds = {}
|
||||
for spaceId, _ in pairs(spaceMap) do
|
||||
table.insert(spaceIds, spaceId)
|
||||
end
|
||||
|
||||
local winMap = {}
|
||||
for _, spaceId in pairs(spaceIds) do
|
||||
for _, winId in ipairs(spaces.windowsForSpace(spaceId)) do
|
||||
winMap[winId] = true
|
||||
end
|
||||
end
|
||||
|
||||
for winId, _ in pairs(winMap) do
|
||||
-- Cannot get windows for non-active spaces, window.filter would have to be used, but performance is crap
|
||||
local win = window.get(winId)
|
||||
if win ~= nil then
|
||||
local name = win:application():name()
|
||||
local def = appScreenMap[name]
|
||||
if def ~= nil then
|
||||
if def.desktop ~= nil and currentSpaces[def.screen] ~= nil then
|
||||
print(v.kCGWindowOwnerName .. " moving window into an index " .. def.desktop .. " which is space " .. currentSpaces[def.screen][def.desktop])
|
||||
print(name .. " moving window into an index " .. def.desktop .. " which is space " .. currentSpaces[def.screen][def.desktop])
|
||||
spaces.moveWindowToSpace(win, currentSpaces[def.screen][def.desktop])
|
||||
end
|
||||
|
||||
local scr = screens[def.screen]
|
||||
if scr ~= nil then
|
||||
timer.doAfter(1, function()
|
||||
print(v.kCGWindowOwnerName .. " moving window into a screen " .. def.screen)
|
||||
print(name .. " moving window into a screen " .. def.screen)
|
||||
|
||||
win:moveToScreen(scr)
|
||||
if def.fullscreen then
|
||||
timer.doAfter(1, function()
|
||||
print(v.kCGWindowOwnerName .. " fullscreening window")
|
||||
print(name .. " fullscreening window")
|
||||
|
||||
fullscreen(win)
|
||||
end)
|
||||
@ -90,6 +116,7 @@ return (function()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- https://github.com/Hammerspoon/hammerspoon/blob/master/SPOONS.md#hotkeys
|
||||
function spoon:bindHotKeys(mapping)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user