Skip to content

Show the actual Triggerhappy state instead of defaulting to off - #788

Open
Gjuju wants to merge 1 commit into
moode-player:developfrom
Gjuju:contrib/triggerhappy-state-from-systemd
Open

Show the actual Triggerhappy state instead of defaulting to off#788
Gjuju wants to merge 1 commit into
moode-player:developfrom
Gjuju:contrib/triggerhappy-state-from-systemd

Conversation

@Gjuju

@Gjuju Gjuju commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

usb_volknob is a session-only , but the state that actually persists across reboots is triggerhappy's service enable state — the usb_volknob job does systemctl enable/disable. The session var is only a mirror of it.

When the session var is missing, worker.php assumed off and wrote that default.
After any session reset the UI then reports the USB volume knob as off while thd is still enabled and running, and the toggle can no longer turn it off: per-config.php submits the job only when the posted value differs from the session one, so clicking OFF on an already-0 session var is a no-op — you have to go ON then OFF to regain control.

This refreshes the session var from systemctl is-enabled triggerhappy at every worker start, so the UI and the worker: log line show the running state.

Note: led_state has no equivalent fix — nothing persists it outside the session file, and at boot /sys/class/leds still holds the firmware default, so reading it back would yield the same 1,1 as today.

@moodeaudio

Copy link
Copy Markdown
Contributor

What would cause the session var to be deleted after its initially set to the default of 0?

@Gjuju

Gjuju commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

It's a marginal case.

Any Pi user restoring a backup hits this: backup_manager.py extracts moodecfg.ini to /boot, autocfg then sets usb_volknob via setSessVarOnly, so the UI comes back showing On while triggerhappy was never really re-enabled.

@Gjuju
Gjuju force-pushed the contrib/triggerhappy-state-from-systemd branch 3 times, most recently from 70b8675 to 1f38b96 Compare August 23, 2026 11:46
@Gjuju
Gjuju force-pushed the contrib/triggerhappy-state-from-systemd branch 2 times, most recently from 3b2d277 to 99cc55f Compare September 1, 2026 10:08
@Gjuju
Gjuju force-pushed the contrib/triggerhappy-state-from-systemd branch from 99cc55f to 61d7471 Compare September 8, 2026 07:44
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.
@Gjuju
Gjuju force-pushed the contrib/triggerhappy-state-from-systemd branch from 61d7471 to 3564c40 Compare September 9, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants