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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# AGENTS.md
Guidance for AI coding agents working in this repository.
## What this is
`deck-it` turns an Android tablet into a second monitor, a stream-deck and an
always-on control surface for a Slackware Hyprland desktop. The PC serves a web
page on a Unix socket and exposes it to the tablet with `adb reverse`; `wayvnc`
streams a headless output to AVNC. Python 3.11+ standard library, plus
`websocket-client` for obs-websocket. Plain HTML/CSS/JS frontend, bash launcher.
Keep the server dependency-free apart from that one package.
## How it fits together
- `deckit/server.py` is the stdlib HTTP server: it listens on
`$XDG_RUNTIME_DIR/deck-it/http.sock`, serves `static/`, `/theme.css`,
`/icons/<name>.svg` and `/api/<module>[/<action>]`.
- A module is `deckit/modules/<name>.py` exporting `make(cfg) -> Module`; the
registry discovers files lazily. `state()` is read, `actions` are
allow-listed, and the client sends ids, never commands.
- The page shell (`static/app.js`) builds tabs from each panel's `tab` property,
mounts those panels and polls `/api/<module>`. The Dashboard tab is
`static/dashboard.js`: one fixed screen with no drag, resize or fold. A top
band of chips (stats, Claude usage from `llm`, tablet battery and Wi-Fi),
music and spending (`llm`) always on, a running row of one to three busy
modules, and the action icons. A panel that can be running exports
`busy(state)` and `slot(state, el)` (`k1c.js`, `sbbuilder.js`, `obs.js`); a
slot builds its markup once and then only sets text, so its scrolling lines
are not restarted. Hyprland's border colours (`--udt-border-1..3`) colour
the trend lines and progress bars and rotate around the action icons.
- `stats` also carries `updates`, keystone's "to install" count from
`updatesctl` (`[dashboard] updates`, empty hides it), re-read in a thread
every 5 min so its NFS reads never stall the 1s poll.
- `actions` serves the Dashboard's icons: `[dashboard] actions`, ids from
`config.ACTION_IDS`, each a fixed command (`screenshot` runs
`qar-scrotmenu.sh`, `lock` runs `lock.sh`). Its watcher checks `pidof
hyprlock` every 2s and sends the tablet `KEYCODE_SLEEP` on lock and
`KEYCODE_WAKEUP` on unlock, for every lock, not only the button.
- `deckit/theme.py` reads UDT's palette (`~/.config/rofi/udt/palette.rasi`) and
`~/.cache/udt/udt-border.lua`; the frontend uses only those CSS variables.
Text size is keystone's (`~/.config/keystone/fonts.json`, `override.deckit`
else `base`) as `--udt-font-size` on `html`, so `deck.css` sizes text in
`rem`. The shell re-reads `/theme.css` every 5s, so changes reach an open page.
- Launcher icons follow the icon theme Keystone sets (`gsettings
org.gnome.desktop.interface icon-theme`); window icons resolve through the
`.desktop` `Icon`/`StartupWMClass` mapping.
- `deckit/display.py` creates the headless output, centres it under the first
monitor for `position = "auto-below"`, and paints it with the first monitor's
swaybg image.
- The launcher (`deck-it`) handles USB and Wi-Fi (`pair`/`wifi`), the tunnels,
wayvnc and AVNC. `adb mdns` may be unsupported; `deck-it wifi <ip:port>` or
`[wifi] address` gives an explicit one; otherwise the last address that
worked (`~/.config/deck-it/last-wifi`, kept across `stop` and reboots).
`[display] enabled = false` skips the headless output, wayvnc and AVNC.
`deck-it status` prints one JSON line for keystone's page; keep its keys.
- Config: `deckit/config.py` merges `~/.config/deck-it/config.toml` over the
shipped `config.toml` per key within each table (a list is replaced whole).
Keystone's deck-it page (quickshell repo, `desktop/modules/deckit`) writes
that sparse file and reads the defaults from `deck-it defaults`; keep that
JSON shape stable.
- A panel whose source can be switched off (OBS, build VM, LLM, K1C) shows
`static/offline.js`'s card, not raw error text; the error goes in its tooltip.
- `k1c` reads a Klipper printer through Moonraker (`[k1c] url`); its one action
is the emergency stop, a press-and-hold button on the tab. While the printer
is off it backs off 10s between tries. The camera snapshot and the slicer
thumbnail are loaded by the tablet straight from the printer.
- `tablet` reads the tablet's battery (`dumpsys battery`) and Wi-Fi (`cmd wifi
status`, Android 11+) over adb, from the device whose reverse carries the
dashboard socket; reads are cached 10s.
- `assistant` is a client of desktop-assistant's socket
(`$XDG_RUNTIME_DIR/desktop-assistant.sock`, JSON lines; every client sees
every event); a reader thread folds events into the state the tab polls
every 0.5s. Presets, ops and paths come from quickshell's
`qs -p <[assistant] shell> ipc call assistant catalog`. Files are picked
on the PC with qarma, never named by the tablet. Voice is a WAV upload
(`Module.uploads`, a raw body with its own size limit) written to the run
dir and asked with `audio`. The tab's icons are the Nerd Font the server
serves at `/fonts/nerd.ttf`; Markdown goes through `static/md.js`
(vendored `marked`, HTML escaped, images never fetched).
- The page holds a Screen Wake Lock while visible, so the tablet never sleeps
over the dashboard. After `[tablet] dim_after` seconds untouched, `app.js`
covers the page with `#dimmer` and `tablet`'s `dim` action sets the
backlight to `dim_brightness` over adb (auto brightness off meanwhile); the
touch on the cover calls `undim`, which puts both back, as does the
module's `stop`.
Before a suspend, poweroff or reboot `deckit/sleep.py` (an elogind delay
inhibitor plus `dbus-monitor` on PrepareForSleep/PrepareForShutdown) marks
answers with `X-Deckit-Sleep: asleep|shutting down` for 2s, and `app.js`
covers the page with "The PC is <that>" and drops the lock (a shutdown then
runs `deck-it stop`; login starts it again), so the tablet sleeps too; 15s with no answer at all gives the same
overlay as "The PC is not answering". The first plain answer takes both back.
- The Windows tab's previews are `grim -T <stableId>` (Hyprland's stableId is
the ext-foreign-toplevel identifier), served at `/api/windows/image/<id>`
through `Module.image`, only for a window the last state listed; the URL
changes every 5s so the browser cache answers in between. Workspace icons
come from keystone's `Workspaces.qml` map (`[windows] workspace_icons`).
- A panel may export `peek(state)`; when it returns seconds > 0 `app.js`
shows that tab that long and then goes back, unless the page is touched or
the tab changed meanwhile. `windows.js` peeks on a window id the last poll
lacked, for `[windows] peek` seconds (0 off).
- Launchers are `[launch] apps`, desktop ids run with `gtk-launch`; label and
icon come from the `.desktop` file. The client sends the id, which must be
configured and installed.
## Conventions
- New behaviour goes in a module under `deckit/modules/`, not in the server.
- Panels keep their scoped wrapper class (`.music`, `.k1c`, `.windows`)
because the CSS is scoped to it.
- Hyprland Lua: a dispatcher must be wrapped in `hl.dispatch(...)` to execute.
`hyprctl eval` alone only builds the dispatcher object.
- No personal data in code, docs, tests or commits; use placeholders.
## Testing
python3 -m unittest discover -s tests
`node --check` any changed JS file. The `tests/test_*.mjs` node checks run
inside the suite through `tests/test_js.py`. The real hardware paths (wayvnc, adb, OBS,
the tablet) are manual.
## Repo facts
- License: GPLv2 only (`LICENSE`, header in each source file).
- Work directly on master.
|