Repository navigation
Expand file tree
/
Copy pathworkspaces.lua
More file actions
49 lines (43 loc) · 1.55 KB
/
Copy pathworkspaces.lua
File metadata and controls
49 lines (43 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
-- plugins/workspaces.lua
-- Workspaces per output, with actions for shortcuts. Panels see them over
-- ext-workspace-v1.
--
-- local ws = plugin("@boring/workspaces"):mount({
-- count = 9, -- per output
-- names = { "web", "code" }, -- optional; the rest are numbered
-- })
-- ["Mod4+1"] = ws.actions.switch(1),
-- ["Mod4+Shift+1"] = ws.actions.send(1),
-- ["Mod4+Tab"] = ws.actions.next,
--
-- Needs a layout plugin (stacking, tiling, kiosk): workspaces are spaces.
local workspaces = require("@boring/library/workspaces")
local plugin = { name = "workspaces" }
function plugin:mount(config, ctx)
workspaces.configure({ count = config.count or 9, names = config.names })
-- Unmounted for good (not remounted by the same reload): back to one.
ctx.scope:defer(workspaces.reset_soon)
local actions = {}
function actions.switch(i)
return function() workspaces.switch(i) end
end
function actions.send(i)
return function()
local w = boring.focused()
if w then workspaces.send(w, i) end
end
end
--- Send the focused window and follow it.
function actions.take(i)
return function()
local w = boring.focused()
if w then workspaces.send(w, i) end
workspaces.switch(i)
if w then boring.focus(w) end
end
end
function actions.next() workspaces.step(1) end
function actions.previous() workspaces.step(-1) end
return { actions = actions, workspaces = workspaces }
end
return plugin