diff --git a/home-manager/hammerspoon/C3CWorkspace.spoon/init.lua b/home-manager/hammerspoon/C3CWorkspace.spoon/init.lua index 9823893..71b89b3 100644 --- a/home-manager/hammerspoon/C3CWorkspace.spoon/init.lua +++ b/home-manager/hammerspoon/C3CWorkspace.spoon/init.lua @@ -1,10 +1,9 @@ return (function() - local application = hs.application local grid = hs.grid local screen = hs.screen local spaces = hs.spaces local timer = hs.timer - local wf = hs.window.filter + local window = hs.window spoon = { name = "C3C Workspace"; @@ -33,8 +32,7 @@ return (function() fullscreen = true, }, ["zoom.us"] = { - desktop = 2, - screen = "D3142823-261D-46EF-B9C2-5181C7FE2CA5", + screen = "B5A65BB6-E73E-4C3D-977C-33C86798AA5A", fullscreen = true, }, ["Microsoft Outlook"] = { @@ -65,45 +63,30 @@ return (function() local currentSpaces = spaces.allSpaces() - local foundWindows = {} - - for appName, def in pairs(appScreenMap) do - local scr = screens[def.screen] - if scr ~= nil then - local app = application.get(appName) - 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]) + 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 + 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]) spaces.moveWindowToSpace(win, currentSpaces[def.screen][def.desktop]) end - print(appName .. " scheduling timer to move window into a screen") - timer.doAfter(1, function() - print(appName .. " moving window into a screen " .. def.screen) + local scr = screens[def.screen] + if scr ~= nil then + timer.doAfter(1, function() + print(v.kCGWindowOwnerName .. " moving window into a screen " .. def.screen) - win:moveToScreen(scr) - if def.fullscreen then - timer.doAfter(1, function() - print(appName .. " fullscreening window") + win:moveToScreen(scr) + if def.fullscreen then + timer.doAfter(1, function() + print(v.kCGWindowOwnerName .. " fullscreening window") - fullscreen(win) - end) - end - end) + fullscreen(win) + end) + end + end) + end end end end