Skip to content

TrimUI: dedicated OSD event watchdog and FN switch status synchronization - #1703

Open
leslieclemence wants to merge 1 commit into
spruceUI:Developmentfrom
leslieclemence:feature/trimui-osd-sync-watchdog
Open

leslieclemence wants to merge 1 commit into
spruceUI:Developmentfrom
leslieclemence:feature/trimui-osd-sync-watchdog

Conversation

@leslieclemence

Copy link
Copy Markdown

Per request by @chrisj951 on #1681, this PR introduces a dedicated osd_sync_watchdog.sh for TrimUI OSD events rather than mixing OSD handlers into volume_sync_watchdog.sh.

Motivation & Background

On TrimUI devices with stock OSDD active (such as the Smart Pro and Smart Pro S), interactions in the Quick Menu / OSD (Cooler level, LED, Wi-Fi, Bluetooth, Rumble) drop event command files into /tmp/system/.
Furthermore, flipping the physical FN switch on the console executes scene-rgb-led.sh to turn LEDs on/off, but previously did not update the shared memory (shmvar ledswitch) or /tmp/trimui_osd/toggle_led/status, leaving the OSD tile out-of-sync with hardware.

Key Changes:

  1. Dedicated osd_sync_watchdog.sh (spruce/scripts/osd_sync_watchdog.sh):
    • Watches /tmp/system/ using event-driven inotifywait (with an interval polling fallback).
    • Handles:
      • set_fanlevel / set_fan: calls apply_fan_level and save_fan_level.
      • led_turn_on / led_turn_off: controls RGB LEDs, removes/sets leds_forced_off flag, and syncs shmvar ledswitch & /tmp/trimui_osd/toggle_led/status.
      • wifi_turn_on / wifi_turn_off: controls wifi, updates SYSTEM_JSON, shmvar wifiswitch, and OSD status.
      • bluetooth_turn_on / bluetooth_turn_off: manages bluetooth daemon, updates SYSTEM_JSON, shmvar btswitch, and OSD status.
      • rumble_turn_on / rumble_turn_off: sets /sys/class/motor/max_scale, gives a tactile pulse, and syncs shmvar rumbleswitch & OSD status.
    • Leaves volume_sync_watchdog.sh 100% focused on ALSA volume.
  2. Immediate OSD Status Sync on FN Switch:
    • spruce/scripts/FN_Button/scene-rgb-led.sh and fn-led-toggle.sh: Updates shmvar ledswitch and /tmp/trimui_osd/toggle_led/status on the very first lines, ensuring zero-latency UI status synchronization.
  3. Isolated Launch in trimui_delegate.sh:
    • Launches osd_sync_watchdog.sh solely on TrimUI devices where /usr/trimui/osd/trimui_osdd is present.

Hardware Testing:

  • Verified on TrimUI Smart Pro S:
    • Flipping FN switch immediately syncs OSD LED tile between ON and OFF.
    • Toggling Rumble in OSD immediately applies motor scale and gives a tactile confirmation pulse.
    • Toggling Fan, Wi-Fi, and Bluetooth in OSD properly applies hardware state and updates system configs.

@chrisj951 chrisj951 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing the hooks in Saves/spruce/spruce-config.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants