From b5184d0e1db1b1d271c74d9dd19ebd0430848342 Mon Sep 17 00:00:00 2001 From: Julien Gainza Date: Thu, 13 Aug 2026 18:20:04 +0200 Subject: [PATCH] Show the actual Triggerhappy state instead of defaulting to off usb_volknob became a session-only var in f6d4b07, but the state that actually persists across reboots is the service enable state. When the session var is missing the worker assumed off and wrote that default, so after any session reset the UI reported the USB volume knob as off while thd kept running, and the toggle could no longer turn it off: per-config.php only submits the job when the posted value differs from the session one, so clicking OFF on an already-0 session var is a no-op. Refresh the session var from `systemctl is-enabled triggerhappy` at every worker start so the UI and the worker log reflect the running state. --- www/daemon/worker.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/www/daemon/worker.php b/www/daemon/worker.php index 1a8d1a800..6e80fa812 100755 --- a/www/daemon/worker.php +++ b/www/daemon/worker.php @@ -1507,9 +1507,10 @@ workerLog('worker: DSI rotate: ' . $_SESSION['dsi_scn_rotate']); workerLog('worker: --'); // Log Triggerhappy / USB volume knob on/off state -if (!isset($_SESSION['usb_volknob'])) { - $_SESSION['usb_volknob'] = '0'; -} +// The service enable state is what persists across reboots, so refresh the +// session var from it rather than defaulting to off +$result = sysCmd('systemctl is-enabled triggerhappy 2>/dev/null'); +$_SESSION['usb_volknob'] = (isset($result[0]) && $result[0] == 'enabled') ? '1' : '0'; workerLog('worker: Triggerhappy: ' . ($_SESSION['usb_volknob'] == '1' ? 'on' : 'off')); // Start rotary encoder if (!isset($_SESSION['rotaryenc'])) {