diff options
| -rw-r--r-- | config.toml | 6 | ||||
| -rw-r--r-- | deckit/config.py | 5 | ||||
| -rw-r--r-- | tests/test_config.py | 9 |
3 files changed, 19 insertions, 1 deletions
diff --git a/config.toml b/config.toml index f32b3f5..38d4794 100644 --- a/config.toml +++ b/config.toml @@ -49,6 +49,7 @@ llm = true sbbuilder = true k1c = true assistant = true +actions = true [obs] host = "127.0.0.1" @@ -100,3 +101,8 @@ theme = "candy-icons" # extension, in order. Each shows its app's icon and runs through gtk-launch; # the client sends the id, never a command. apps = ["kitty", "pcmanfm-qt", "com.obsproject.Studio", "firefox", "signal-desktop"] + +[dashboard] +# Icon buttons at the bottom of the Dashboard, in order. Each id runs a fixed +# command on the PC: screenshot opens qar-scrotmenu.sh, lock runs lock.sh. +actions = ["screenshot", "lock"] diff --git a/deckit/config.py b/deckit/config.py index e20bc00..6ce0cba 100644 --- a/deckit/config.py +++ b/deckit/config.py @@ -26,6 +26,8 @@ ROOT = Path(__file__).resolve().parent.parent MONITOR_NAME = re.compile(r"[A-Za-z0-9_-]{1,32}") WIFI_ADDR = re.compile(r"[A-Za-z0-9.-]{1,253}:[0-9]{1,5}") DESKTOP_ID = re.compile(r"[A-Za-z0-9._-]{1,255}") +# The dashboard's action buttons; deckit/modules/actions.py maps each to its command. +ACTION_IDS = ("screenshot", "lock") def user_config_path() -> Path: @@ -54,6 +56,9 @@ def config_error(cfg: dict) -> str | None: apps = cfg.get("launch", {}).get("apps", []) if not isinstance(apps, list) or not all(isinstance(a, str) and DESKTOP_ID.fullmatch(a) for a in apps): return "launch.apps must be a list of desktop ids, like \"kitty\"" + acts = cfg.get("dashboard", {}).get("actions", []) + if not isinstance(acts, list) or not all(a in ACTION_IDS for a in acts): + return f"dashboard.actions must be a list of: {', '.join(ACTION_IDS)}" return None diff --git a/tests/test_config.py b/tests/test_config.py index 928a8e8..906d8d3 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -39,10 +39,17 @@ class Config(unittest.TestCase): {"ports": {"command_center": 80}}, {"ports": {"command_center": 5900, "display": 5900}}, {"wifi": {"address": "x; rm -rf ~"}}, - {"launch": {"apps": ["ok", "../evil"]}}] + {"launch": {"apps": ["ok", "../evil"]}}, + {"dashboard": {"actions": ["screenshot", "rm -rf"]}}, + {"dashboard": {"actions": "lock"}}] for cfg in bad: self.assertIsNotNone(config.config_error(cfg), cfg) + def test_dashboard_actions(self): + self.assertIsNone(config.config_error({"dashboard": {"actions": []}})) + self.assertIsNone(config.config_error({"dashboard": {"actions": ["lock", "screenshot"]}})) + self.assertEqual(config.ACTION_IDS, ("screenshot", "lock")) + def test_user_file_overrides_key_by_key(self): cfg = config.merge({"display": {"enabled": True, "scale": 1}, "launch": {"apps": ["a", "b"]}}, {"display": {"enabled": False}, "launch": {"apps": ["c"]}}) |
