Improve hammerspoon workspace management
This commit is contained in:
parent
a12585068a
commit
143830ce27
@ -1,10 +1,9 @@
|
|||||||
return (function()
|
return (function()
|
||||||
local application = hs.application
|
|
||||||
local grid = hs.grid
|
local grid = hs.grid
|
||||||
local screen = hs.screen
|
local screen = hs.screen
|
||||||
local spaces = hs.spaces
|
local spaces = hs.spaces
|
||||||
local timer = hs.timer
|
local timer = hs.timer
|
||||||
local wf = hs.window.filter
|
local window = hs.window
|
||||||
|
|
||||||
spoon = {
|
spoon = {
|
||||||
name = "C3C Workspace";
|
name = "C3C Workspace";
|
||||||
@ -33,8 +32,7 @@ return (function()
|
|||||||
fullscreen = true,
|
fullscreen = true,
|
||||||
},
|
},
|
||||||
["zoom.us"] = {
|
["zoom.us"] = {
|
||||||
desktop = 2,
|
screen = "B5A65BB6-E73E-4C3D-977C-33C86798AA5A",
|
||||||
screen = "D3142823-261D-46EF-B9C2-5181C7FE2CA5",
|
|
||||||
fullscreen = true,
|
fullscreen = true,
|
||||||
},
|
},
|
||||||
["Microsoft Outlook"] = {
|
["Microsoft Outlook"] = {
|
||||||
@ -65,45 +63,30 @@ return (function()
|
|||||||
|
|
||||||
local currentSpaces = spaces.allSpaces()
|
local currentSpaces = spaces.allSpaces()
|
||||||
|
|
||||||
local foundWindows = {}
|
for _, v in pairs(window.list()) do
|
||||||
|
local def = appScreenMap[v.kCGWindowOwnerName]
|
||||||
for appName, def in pairs(appScreenMap) do
|
local win = window.get(v.kCGWindowNumber)
|
||||||
local scr = screens[def.screen]
|
if def ~= nil and win ~= nil then
|
||||||
if scr ~= nil then
|
if def.desktop ~= nil and currentSpaces[def.screen] ~= nil then
|
||||||
local app = application.get(appName)
|
print(v.kCGWindowOwnerName .. " moving window into an index " .. def.desktop .. " which is space " .. currentSpaces[def.screen][def.desktop])
|
||||||
if app then
|
|
||||||
local appFilter = wf.new(appName)
|
|
||||||
if appFilter then
|
|
||||||
-- TODO: Really bad performance
|
|
||||||
foundWindows[appName] = appFilter:getWindows()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for appName, windows in pairs(foundWindows) do
|
|
||||||
local def = appScreenMap[appName]
|
|
||||||
local scr = screens[def.screen]
|
|
||||||
|
|
||||||
for _, win in pairs(windows) do
|
|
||||||
if currentSpaces[def.screen] ~= nil then
|
|
||||||
print(appName .. " moving window into an index " .. def.desktop .. " which is space " .. currentSpaces[def.screen][def.desktop])
|
|
||||||
spaces.moveWindowToSpace(win, currentSpaces[def.screen][def.desktop])
|
spaces.moveWindowToSpace(win, currentSpaces[def.screen][def.desktop])
|
||||||
end
|
end
|
||||||
|
|
||||||
print(appName .. " scheduling timer to move window into a screen")
|
local scr = screens[def.screen]
|
||||||
timer.doAfter(1, function()
|
if scr ~= nil then
|
||||||
print(appName .. " moving window into a screen " .. def.screen)
|
timer.doAfter(1, function()
|
||||||
|
print(v.kCGWindowOwnerName .. " moving window into a screen " .. def.screen)
|
||||||
|
|
||||||
win:moveToScreen(scr)
|
win:moveToScreen(scr)
|
||||||
if def.fullscreen then
|
if def.fullscreen then
|
||||||
timer.doAfter(1, function()
|
timer.doAfter(1, function()
|
||||||
print(appName .. " fullscreening window")
|
print(v.kCGWindowOwnerName .. " fullscreening window")
|
||||||
|
|
||||||
fullscreen(win)
|
fullscreen(win)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user