return (function() local grid = hs.grid local screen = hs.screen local spaces = hs.spaces local timer = hs.timer local window = hs.window spoon = { name = "C3C Workspace"; version = "0.0.1"; author = "Arnie"; license = "MIT"; } -- DELL S2722DGM: 0F6BDB5B-840D-40BE-AAC9-B467A78E057A -- DELL S2721DGF: D3142823-261D-46EF-B9C2-5181C7FE2CA5 -- AV Receiver: B5A65BB6-E73E-4C3D-977C-33C86798AA5A local appScreenMap = { Slack = { desktop = 1, screen = "0F6BDB5B-840D-40BE-AAC9-B467A78E057A", fullscreen = true, }, Cursor = { desktop = 1, screen = "B5A65BB6-E73E-4C3D-977C-33C86798AA5A", fullscreen = true, }, Spotify = { desktop = 3, screen = "B5A65BB6-E73E-4C3D-977C-33C86798AA5A", fullscreen = true, }, ["zoom.us"] = { screen = "B5A65BB6-E73E-4C3D-977C-33C86798AA5A", fullscreen = true, }, ["Microsoft Outlook"] = { desktop = 3, screen = "D3142823-261D-46EF-B9C2-5181C7FE2CA5", fullscreen = true, }, } local fullscreen = function(win) local screen = win:screen() local cell = grid.get(win, screen) cell.x = 0 cell.y = 0 cell.w = 24 cell.h = 24 grid.set(win, cell, screen) end function spoon:restoreAppsToScreens() local screens = {} for _, scr in ipairs(screen.allScreens()) do screens[scr:getUUID()] = scr end 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 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 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(v.kCGWindowOwnerName .. " fullscreening window") fullscreen(win) end) end end) end end end end -- https://github.com/Hammerspoon/hammerspoon/blob/master/SPOONS.md#hotkeys function spoon:bindHotKeys(mapping) local spec = { restoreAppsToScreens = hs.fnutils.partial(self.restoreAppsToScreens, self) } hs.spoons.bindHotkeysToSpec(spec, mapping) return self end return spoon end)()