#!/bin/sh /etc/rc.common
# Long-running daemon that watches the backlight power state for the
# power-button combination (3 short presses in 5 seconds) and, when
# detected, launches the configured overlay action.

START=85
STOP=10
USE_PROCD=1

NOMAD_HOME="/etc/nomad"

# buttond runs FOR REAL: it is the watchdog scheduler on LCD devices
# (buttond.run() -> watchdog.tick_all()), and those background automations
# (wan_aware airplane, boot-time sticky hardening, …) must actually mutate
# device state, exactly like the standalone nomad-watchdog service does on
# non-LCD models. A blanket NOMAD_DRY_RUN here used to silently simulate all
# of them. Dry-run for the *interactive* on-device flow (the LCD session +
# the SIM-swap / IMEI rewrites it dispatches) is now injected per-spawn in
# buttond._spawn_action(), not process-wide.
start_service() {
    procd_open_instance
    procd_set_param command sh -c "PYTHONPATH=$NOMAD_HOME exec python3 -m nomad.cli button monitor"
    procd_set_param respawn 5 5 10
    procd_set_param stdout 1
    procd_set_param stderr 1
    procd_close_instance
}
