[Unit]
Description=LCXL LED watcher (track-aware surface paint, #78/#85)
Documentation=file:///home/pln/Work/Sound/Tidal/tools/lcxl-leds.py
# The LCXL is hot-pluggable and often absent at boot. Rather than bind to a
# device unit (whose name changes with the USB topology), this unit simply
# retries forever. Plug the board in and it lights up within RestartSec.
#
# StartLimitIntervalSec=0 lives HERE, in [Unit] — systemd silently ignores it in
# [Service] ("Unknown key ... ignoring"), which would leave the default limit of
# 5 restarts / 10 s in force and let the unit fall into `failed` with the board
# dark for the rest of the session. Exactly the silent-failure shape this rig
# keeps getting bitten by, one section heading away.
StartLimitIntervalSec=0

[Service]
Type=simple
WorkingDirectory=/home/pln/Work/Sound/Tidal
# Python BLOCK-buffers stdout when it is a pipe, and under systemd it always is.
# So this unit produced no journal output beyond systemd's own lines, and its
# track-change diagnostics never reached the journal — which is why take 94 could
# not be explained from the logs even though the watcher ran throughout it. A
# daemon whose diagnostics sit unflushed in a 4 KB buffer is a daemon with none.
Environment=PYTHONUNBUFFERED=1
ExecStart=/usr/bin/python3 /home/pln/Work/Sound/Tidal/tools/lcxl-leds.py --watch -q

Restart=always
RestartSec=10

# It must never be the reason audio stutters. The watcher forks a helper per LED
# write (a known cost — one fork+exec per LED), so cap it below every audio thread.
# Measured: 2.1 s CPU over 1 h 53 m wall = 0.03% of a core. It is not the problem.
Nice=5
CPUWeight=20
IOWeight=20

[Install]
WantedBy=default.target
