Sync Brick Fn actions and the volume keys with spruce state#1549
Open
Felixmil wants to merge 9 commits into
Open
Sync Brick Fn actions and the volume keys with spruce state#1549Felixmil wants to merge 9 commits into
Felixmil wants to merge 9 commits into
Conversation
- com.trimui.switch.backlight.sh: - source helperFunctions and cycle via spruce set_backlight / current_backlight - cycle levels 1, 4, 7, 10 then wrap, keeping hardware, stored value and UI slider in sync - drop the stock /tmp/system/set_brightness path that spruce does not honor
- com.trimui.silent.sh: - source helperFunctions and drop volume to 0 via spruce set_volume on enter, so the in-UI volume value reflects the mute - save the prior volume and restore it via set_volume on exit - keep the speaker hard-mute as a backstop
- App/fn_editor/com.trimui.quiet.sh: - source spruce helperFunctions for set_volume / get_volume_level - on enter, save the current volume then set spruce volume to a low level - on exit, restore the saved volume and clean up the temp file - drop the tinymix mixer pokes that spruce did not read or respect
- spruce/scripts/platform/device_functions/trimui_a133p.sh: - add an optional SHOW_OSD third arg to set_volume (defaults to true) - only show the stock volume popup when SHOW_OSD is true - App/fn_editor/com.trimui.silent.sh: - pass "true false" to set_volume so the config syncs without the popup - App/fn_editor/com.trimui.quiet.sh: - pass "true false" to set_volume so the config syncs without the popup
- spruce/brick/volume_sync_watchdog.sh: - add a watcher that polls /tmp/system/set_volume and mirrors the value into spruce's stored volume via set_volume (config only, OSD suppressed) so the in-UI volume bar tracks the hardware Volume +/- keys, including while held - spruce/scripts/platform/device_functions/trimui_a133p.sh: - launch volume_sync_watchdog.sh from device_init_a133p - spruce/scripts/save_poweroff.sh: - kill volume_sync_watchdog.sh during shutdown alongside the other watchdogs
- volume_sync_watchdog.sh: - add unmute_if_raised() to clear the speaker amp mute and the muted marker when a non-zero volume arrives - call unmute_if_raised on each observed volume change so volume-up lifts Silent Mode's hard mute without flipping the switch
- trimui_a133p.sh: - remove the volume_sync_watchdog launch from device_init_a133p, where the bare background job started during early-boot churn and did not survive - add a launch_startup_watchdogs override that runs the common watchdogs then starts volume_sync_watchdog alongside them, pinned to the system CPU like its siblings
…nfig - volume_sync_watchdog.sh: - react to /tmp/system/set_volume via inotifywait instead of a 150ms poll, so the bar tracks held volume keys without the sampling delay - mirror only into SYSTEM_JSON (the file PyUI polls) and drop the set_volume call, since the firmware already owns the durable /mnt/UDISK copy and ALSA; this removes a redundant synchronous flash write from each ramp step - keep the Silent Mode unmute and add a polling fallback for when inotifywait is unavailable
- trim_ui_brick.py: - lower the system-config FileWatcher interval from 0.2s to 0.05s so the volume bar redraws within ~50ms of the volume sync watchdog mirroring a new level, instead of trailing by up to 200ms while a key is held
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The TrimUI Brick "Fn Key and Switch Settings" actions are stock scripts that write to firmware sinks spruce does not use, so their effects did not stay in sync with spruce's own state. This reworks three of those actions to go through spruce's own helpers, so the hardware, the stored value, and the in-UI sliders all move together. It also stops the audio actions from triggering the stock volume popup, which was redundant with the switch's own on-screen toast, and adds a watcher so the in-UI volume bar follows the physical volume keys.
Backlight action
The "LCD brightness switcher" action wrote the new level to
/tmp/system/set_brightnessfor the stockhardwareserviceto apply, which spruce does not consume, so the brightness slider and stored value did not follow the key. It now sourceshelperFunctions.shand cycles the backlight with spruce'scurrent_backlight/set_backlight, stepping through 1, 4, 7, 10 and wrapping back to 1. Becauseset_backlightrecords the value spruce reads elsewhere, the UI slider updates in step.Silent Mode action
Silent Mode hard-muted the speaker via
/sys/class/speaker/mutebut never told spruce, so the in-UI volume value stayed at its old level while muted. It now also drops the volume to 0 through spruce'sset_volumeon enter (so the volume value reflects the mute) and restores the prior volume on exit. The speaker hard-mute is kept as a backstop.Quiet Mode action
Quiet Mode poked an ALSA mixer control directly (
tinymix set 9 N), which spruce neither reads nor respects, so nothing audible changed and the volume slider stayed wrong. It now lowers the volume to a low but audible level through spruce'sset_volumeon enter, saving the current volume first, and restores that saved volume on exit, mirroring the Silent Mode approach.Volume popup suppression
In game (when MainUI is not running)
set_volumeshows the stock volume OSD popup. When Silent or Quiet was toggled by the switch this popped up alongside the switch's own toast, which was redundant.set_volumegains an optional third argument that controls the popup (defaulting to shown, so every existing caller is unchanged), and the Silent and Quiet actions opt out of it. The physical volume keys still show their popup as before.Volume key sync
The physical Volume +/- keys are handled entirely by the stock firmware, which adjusts the audio and writes the new level to
/tmp/system/set_volumeon every key event (autorepeat included). spruce never read that file back, so its stored volume (.vol) only changed when spruce itself set the volume. Since the in-UI volume bar reads.vol, holding a volume key moved the audio but the bar updated once at most and never ramped. A small watchdog (spruce/brick/volume_sync_watchdog.sh) now polls/tmp/system/set_volumeand mirrors the value into spruce's volume throughset_volume(config only, with the popup suppressed because the firmware already draws its own), so the bar tracks the hardware keys including while held. It is started fromdevice_init_a133pand stopped on shutdown alongside the other watchdogs.Notes
These changes are independent of the daemon that dispatches Fn key presses (see #1548, which starts
keymon); they only change what the actions do when they run. The Fn key and switch actions in this PR only reach users oncekeymonis also started, but the volume key sync is independent ofkeymonand works on its own. The volume sync watcher is launched next to the line #1548 adds todevice_init_a133p, so merging the two produces a one-line conflict that is resolved by keeping both lines. #1550 edits a different part of the same file (the runtime mounts) and merges independently.Validated on a physical Brick (FW 1.1.1): the backlight cycle runs 1 → 4 → 7 → 10 → 1 with the stored value updating each step, Silent Mode drops the volume value to 0 on enter and restores the previous level on exit, Quiet Mode drops the volume to a low level on enter and restores the previous level on exit, in game the switch no longer shows the stock volume popup for Silent or Quiet while the volume keys still do, and holding the Volume +/- keys now ramps the in-UI volume bar smoothly in sync with the audio.