Commit Graph
4 Commits
Author SHA1 Message Date
maziggy 18238cfeb2 fix(spoolbuddy): apply screen-blank timeout changes live without kiosk restart
Picking a new "Screen Blank Timeout" in SpoolBuddy Settings → Display
  didn't change actual blanking behaviour: whatever value was active when
  the kiosk last booted continued to fire. A user who started with the
  10m preset and switched to 1m or "Off" still saw the screen blank at 10m.

  Cause: blanking is driven by swayidle, started once by spoolbuddy-idle.sh
  at labwc autostart with the timeout passed as a command-line argument.
  The script fetched blank_timeout from the backend exactly once at startup
  and swayidle has no runtime control surface for changing its timeout.
  The daemon's display.set_blank_timeout() updated an in-memory variable
  that was never reached by swayidle, so UI changes were silently discarded
  until the next kiosk restart.

  Fix: extend the wake FIFO protocol with a "reload-timeout N" message.
  The daemon writes it whenever set_blank_timeout() sees a value that
  differs from the current one (the very first call is suppressed because
  the watchdog already fetched the same value at its own startup —
  signalling there would just thrash swayidle on every cold boot). The
  script's FIFO loop is restructured around start_swayidle / stop_swayidle
  helpers and a case statement: wake → wlopm --on + arm a re-blank at the
  current timeout; reload-timeout N → kill running swayidle, set TIMEOUT=N,
  restart swayidle, wlopm --on so the user sees the change took effect
  even if the screen was already blanked. The script de-dupes too — a
  reload-timeout whose N matches the current value is a no-op. Going from
  any positive timeout to 0 ("Off") stops swayidle and doesn't restart
  it; going from 0 to a positive value starts a fresh swayidle. Both work
  without a kiosk restart.

  The script's main loop opens the FIFO read+write (exec 3<>"$WAKE_FIFO")
  so bash read never sees EOF when the daemon momentarily disconnects
  between writes. A cleanup trap on TERM/INT/HUP stops swayidle, removes
  the FIFO, and exits cleanly.
2026-05-05 13:50:08 +02:00
maziggy 66a3604d9b Draft commit message:
fix(spoolbuddy): gate display wake on stable scale reading

  A noisy load cell that bounced ≥50 g around its midpoint kept the kiosk
  screen permanently lit. The wake threshold check ran against last_wake_grams
  which itself advanced to noisy values, so every bounce back across 50 g
  re-fired display.wake(), keeping the FIFO reader pumping wlopm --on
  faster than swayidle could trigger wlopm --off.

  The fix gates wake on the scale's `stable` flag — only readings that
  have settled within 2 g over a 1 s window count as a real spool
  placement / removal. Unstable noise can't fire wake and can't advance
  last_wake_grams, so the next genuine settled change is still measured
  against the right baseline.

  Three regression tests pin the contract: noisy ±60 g unstable readings
  never wake, a settled >50 g jump wakes, a noise burst between two
  settled readings doesn't poison last_wake_grams.
2026-05-03 09:22:35 +02:00
maziggy 2aabbe5d37 fix(spoolbuddy): sync SSH key over heartbeat to survive Bambuddy keypair rotation
Bambuddy's SSH keypair under <DATA_DIR>/spoolbuddy/ssh/ regenerates whenever
  the data dir is recreated (volume remount, container recreate, fresh deploy).
  The daemon previously only fetched the pubkey at registration, so any
  rotation after a successful boot left ~/.ssh/authorized_keys pointing at
  a stale public half — every Update click then failed with "Connection
  closed by authenticating user spoolbuddy [preauth]" until the daemon was
  restarted by hand. Each prior registration also appended a fresh entry
  without pruning, accumulating stale Bambuddy-tagged keys indefinitely.

  - HeartbeatResponse now carries ssh_public_key; the heartbeat route reads
    it via the same try/except shape as the register route so a missing or
    unreadable backend key doesn't break telemetry.
  - _deploy_ssh_key() strips lines tagged bambuddy-spoolbuddy and writes
    the current key once. No-op when already in sync (no mtime churn on
    every heartbeat). User-managed entries are preserved.
  - Daemon heartbeat handler calls _deploy_ssh_key when the response
    carries a key, so rotations propagate within one heartbeat instead
    of requiring a service restart.

  Tests: 5 unit (creates-when-missing, replace-stale-pileup, preserve-user-keys,
  idempotent, swallows-write-errors) + 2 backend integration (heartbeat carries
  the key; backend key-read failure leaves ssh_public_key None but the
  heartbeat still 200s).
2026-05-01 10:44:01 +02:00
maziggy d750e8f0e0 Added Spoolbuddy frontend/backend tests 2026-03-22 12:55:35 +01:00