SmartestHome/stream-dock/upstream-file-watch-request.md

51 lines
2.4 KiB
Markdown

# Ready-to-file request: watch `leds.toml` instead of reading it once
Written to be pasted into an issue on whichever `opendeck-akp05` fork you installed
([aroaxinping](https://github.com/aroaxinping/opendeck-akp05),
[ambiso](https://github.com/ambiso/opendeck-akp05),
[truelecter](https://github.com/truelecter/opendeck-mirabox-n4)). It is the real fix
for the one gap in this directory: everything else is already built and tested.
---
**Title:** Re-read `leds.toml` when it changes, instead of only at plugin start
**Body:**
The knob LEDs are currently configured from `~/.config/opendeck-akp05/leds.toml`,
which the plugin reads at startup. That makes the ring colours a static decoration.
They could be a display. The rings are the only pixels on this device that sit next to
the encoders, and plenty of things an encoder controls have a colour: a light, a
channel strip, a status. In my case the four dials are red / green / blue / brightness
for a room's lamps, and the natural feedback is each ring showing its own channel's
current value, with the fourth showing the colour the room is actually emitting.
Everything needed for that already exists in the plugin — it can set ring colours.
What is missing is a way to change them after startup:
- The plugin holds the USB device open, so no other process can drive the LEDs.
- Nothing documents a reload mechanism, and the file is not watched.
- The workarounds are all bad: restarting the plugin re-initialises the device (a
visible blink and the keys redrawing) for what should be a two-byte change, and it
cannot be done at the rate a turning dial produces changes.
**The ask:** watch `leds.toml` for modification and re-apply on change — the
`notify` crate, or a poll of the file's mtime once a second, would both be enough. A
debounce on the watcher side would be welcome but is not required; a writer that
respects the device can rate-limit itself (mine does).
**Why a file watch rather than an API:** it needs no new IPC surface, no protocol
decision, and no change to how the file is documented today. Anything that can write a
config file can drive the rings.
Happy to test a branch against a MiraBox N4 Pro.
---
## If the answer is no
Nothing in `stream-dock/` has to change. `apply-leds.sh --strategy restart-plugin`
already works as a fallback, paced by `apply_min_interval_seconds`, and the ring
colours are computed and written correctly either way — see `README.md` §5.