aboutsummaryrefslogtreecommitdiffstats
path: root/deckit/modules/windows.py
diff options
context:
space:
mode:
Diffstat (limited to 'deckit/modules/windows.py')
-rw-r--r--deckit/modules/windows.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/deckit/modules/windows.py b/deckit/modules/windows.py
index d02fc0c..8642b1c 100644
--- a/deckit/modules/windows.py
+++ b/deckit/modules/windows.py
@@ -63,6 +63,12 @@ def make(cfg: dict) -> Module:
run = cfg.get("run", _run)
lua = hypr_lua(cfg)
launch = cfg.get("launch", {})
+ workspaces = cfg.get("windows", {}).get("workspaces", list(range(1, 11)))
+
+ def launch_spec(spec):
+ if isinstance(spec, dict):
+ return spec.get("command"), spec.get("icon"), spec.get("label")
+ return spec, None, None
def workspace(body):
n = body.get("n")
@@ -84,13 +90,19 @@ def make(cfg: dict) -> Module:
def launch_key(body):
key = str(body.get("key", ""))
- command = launch.get(key)
+ command, _, _ = launch_spec(launch.get(key))
if command is None:
raise ModuleError("unknown launch key")
_popen(["sh", "-c", command] if isinstance(command, str) else command)
def state():
- return {**_state(run), "launches": list(launch)}
+ st = _state(run)
+ known = sorted(set(int(n) for n in workspaces) | set(st["workspaces"]))
+ launches = []
+ for key, spec in launch.items():
+ _, icon, label = launch_spec(spec)
+ launches.append({"key": key, "icon": icon, "label": label or key})
+ return {**st, "workspaces": known, "launches": launches}
return Module(name="windows", title="Windows", state=state,
actions={"workspace": workspace, "focus": focus, "close": close, "launch": launch_key})