docs: design transactional DDC setup
366b38fba7edd104457f98d93a0adaa22d4cfe7b
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
- Parent 1: fad7c10b0456
bugabingas dorkfiles
366b38fba7edd104457f98d93a0adaa22d4cfe7b
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
+45 / −0 text lines
new file mode 100644+45 / −0 text lines
# ddc setup design## goalTurn brightness DDC setup from an opaque detached command into a transactional, observable setup and control flow.## system contractUse Arch's `ddcutil` package as the persistent system integration. Its package owns `/usr/lib/modules-load.d/ddcutil.conf` and `/usr/lib/udev/rules.d/60-ddcutil-i2c.rules`; Nuguland must not duplicate these under `/etc`.The privileged stage installs `ddcutil`, loads `i2c-dev` for the current session, and retriggers i2c udev devices. All later detection, reads, and writes run unprivileged.## stages1. `preflight`: inspect command availability, module state, device presence, and permissions.2. `authorize`: request Polkit only when package/session setup is incomplete.3. `install`: run the bounded package-native setup command and capture exit status.4. `detect`: run `ddcutil detect --brief`; map DRM connectors to I2C buses.5. `read`: run `ddcutil getvcp 10 --brief` per detected bus and record current/max brightness.6. `verify`: expose only displays that responded successfully as controllable.7. `ready`: retain detected display state and collapse setup UI to a compact `ddc ready` status.## UXThe expanded setup card shows every stage with `waiting`, `running`, `done`, or `failed`, one progress indicator, concise detail, detected displays, retry, close, and copy-diagnostics actions.When every stage is green, the setup card collapses. It can be reopened for diagnostics. Display rows show connector, monitor name, bus, current brightness, and readiness.No stage silently disappears. Running actions disable duplicate submission. Errors identify the failed stage and offer retry from that stage.## errors and diagnosticsCapture process stdout/stderr internally but expose only bounded, redacted summaries. Never include passwords, environment variables, or arbitrary command lines. Diagnostics include stage, exit code, package/module/device/permission state, connector, bus, and sanitized ddcutil message.Timeouts are explicit for detection, reads, and writes. One failed monitor does not disable working monitors. Setup cancellation leaves completed package-native changes intact and reports cancellation.## controlDDC display writes call `ddcutil --bus <n> setvcp 10 <percent>` without root. Successful writes update the row and OSD; failures preserve the previous value and surface an inline error.## testsPure JavaScript owns parsing and stage shaping. Tests cover detect parsing, VCP parsing, stage transitions, partial-monitor failure, redaction, timeout/error shaping, collapsed-ready state, and command argument generation.QML tests verify Process-based setup replaces `execDetached`, setup feedback is rendered, and DDC writes use detected buses. Final gates: `just fmt`, `just test`, `just lint`.