aboutsummaryrefslogtreecommitdiffstats
path: root/deckit/modules
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-09 18:25:59 +0100
committerDanilo M. <danix@danix.xyz>2026-11-09 18:25:59 +0100
commit7f99167f0b6a3c83bf77e20bc5e03942b901fb71 (patch)
tree6b60263b6f702e6088eae30087c6dfa2a5a71f4c /deckit/modules
parent03e2adab3fb58532ba1e32c2f01a9ec14f11e484 (diff)
downloaddeck-it-7f99167f0b6a3c83bf77e20bc5e03942b901fb71.tar.gz
deck-it-7f99167f0b6a3c83bf77e20bc5e03942b901fb71.zip
fix: OBS idle timeout, payload validation, workspace list
Diffstat (limited to 'deckit/modules')
-rw-r--r--deckit/modules/obs.py18
-rw-r--r--deckit/modules/windows.py10
2 files changed, 20 insertions, 8 deletions
diff --git a/deckit/modules/obs.py b/deckit/modules/obs.py
index f4bf71a..96217c4 100644
--- a/deckit/modules/obs.py
+++ b/deckit/modules/obs.py
@@ -18,6 +18,7 @@ def make(cfg: dict) -> Module:
host=o.get("host", "127.0.0.1"), port=o.get("port", 4455), password=o.get("password", ""))
lock = threading.Lock()
stop = threading.Event()
+ last_error = {"msg": None}
def req(kind, data=None):
with lock:
@@ -28,13 +29,14 @@ def make(cfg: dict) -> Module:
if not getattr(client, "connected", False):
try:
client.connect()
- except Exception:
- pass
+ last_error["msg"] = None
+ except Exception as e:
+ last_error["msg"] = str(e) or type(e).__name__
stop.wait(5)
def state():
if not getattr(client, "connected", False):
- return {"connected": False}
+ return {"connected": False, "error": last_error["msg"]}
try:
scenes = req("GetSceneList")
rec = req("GetRecordStatus")
@@ -80,11 +82,17 @@ def make(cfg: dict) -> Module:
raise ModuleError("scene required")
req("SetCurrentProgramScene", {"sceneName": name})
+ def flag(body):
+ on = body.get("on")
+ if not isinstance(on, bool):
+ raise ModuleError('"on" must be true or false')
+ return on
+
def record(body):
- req("StartRecord" if body.get("on") else "StopRecord")
+ req("StartRecord" if flag(body) else "StopRecord")
def stream(body):
- req("StartStream" if body.get("on") else "StopStream")
+ req("StartStream" if flag(body) else "StopStream")
def mute(body):
req("SetInputMute", {"inputName": str(body.get("input")), "inputMuted": bool(body.get("muted"))})
diff --git a/deckit/modules/windows.py b/deckit/modules/windows.py
index 022bdd7..d02fc0c 100644
--- a/deckit/modules/windows.py
+++ b/deckit/modules/windows.py
@@ -45,7 +45,7 @@ def _state(run):
try:
clients = json.loads(run(["hyprctl", "clients", "-j"]) or "[]")
active = json.loads(run(["hyprctl", "activewindow", "-j"]) or "{}").get("address")
- monitors = json.loads(run(["hyprctl", "monitors", "-j"]) or "[]")
+ workspaces = json.loads(run(["hyprctl", "workspaces", "-j"]) or "[]")
except json.JSONDecodeError:
return {"windows": [], "workspaces": [], "activeClass": None}
wins = sorted(
@@ -54,7 +54,8 @@ def _state(run):
for c in clients if c.get("mapped", True) and c["workspace"]["id"] > 0),
key=lambda w: (w["workspace"], w["class"]))
active_class = next((w["class"] for w in wins if w["active"]), None)
- return {"windows": wins, "workspaces": [m["activeWorkspace"]["id"] for m in monitors],
+ return {"windows": wins,
+ "workspaces": sorted(w["id"] for w in workspaces if w.get("id", 0) > 0),
"activeClass": active_class}
@@ -88,5 +89,8 @@ def make(cfg: dict) -> Module:
raise ModuleError("unknown launch key")
_popen(["sh", "-c", command] if isinstance(command, str) else command)
- return Module(name="windows", title="Windows", state=lambda: _state(run),
+ def state():
+ return {**_state(run), "launches": list(launch)}
+
+ return Module(name="windows", title="Windows", state=state,
actions={"workspace": workspace, "focus": focus, "close": close, "launch": launch_key})