Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions spruce/brick/fn_dip/show_fn_dip_off_msg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

#assume no jq binary in system

# Label the switch popup by the configured switch action instead of a plain
# "OFF". The active switch action is the script present in /usr/trimui/scene/;
# map its basename to a short label, falling back to "OFF" when unknown.
STATE="OFF"
SCENE_SH=$(ls /usr/trimui/scene/*.sh 2>/dev/null | head -n1)
BASE=$(basename "$SCENE_SH" 2>/dev/null)
case "$BASE" in
# The LED action is "LED off": switch OFF turns the LEDs back ON, so the
# popup text is inverted relative to the switch state.
com.trimui.ledc.sh) MSG="LED: ON" ;;
com.trimui.quiet.sh) MSG="Quiet: $STATE" ;;
com.trimui.silent.sh) MSG="Silent: $STATE" ;;
com.trimui.joystick.sh|com.trimui.toggle.dpad_joystick.sh) MSG="Joystick: $STATE" ;;
*) MSG="$STATE" ;;
esac

VOL_MSG_JSON="\n\
{ \n\
\"type\":\"default\", \n\
\"id\":\"com.trimui.osd.msg.fneditor_dip\", \n\
\"duration\":1000, \n\
\"size\":0, \n\
\"x\":700, \n\
\"y\":80, \n\
\"w\":300, \n\
\"h\":80, \n\
\"message\":\" $MSG\", \n\
\"font\":\"\", \n\
\"bg\":\"\", \n\
\"icon\":\"/usr/trimui/apps/fn_editor/ic-fn-off-tips.png\", \n\
\"fontsize\":24, \n\
\"fontcolor\":\"FFFFFFFF\" \n\
} \n"

echo -e $VOL_MSG_JSON > /tmp/trimui_osd/osd_toast_msg
#echo -e $VOL_MSG_JSON > dump.txt
40 changes: 40 additions & 0 deletions spruce/brick/fn_dip/show_fn_dip_on_msg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

#assume no jq binary in system

# Label the switch popup by the configured switch action instead of a plain
# "ON". The active switch action is the script present in /usr/trimui/scene/;
# map its basename to a short label, falling back to "ON" when unknown.
STATE="ON"
SCENE_SH=$(ls /usr/trimui/scene/*.sh 2>/dev/null | head -n1)
BASE=$(basename "$SCENE_SH" 2>/dev/null)
case "$BASE" in
# The LED action is "LED off": switch ON turns the LEDs OFF, so the popup
# text is inverted relative to the switch state.
com.trimui.ledc.sh) MSG="LED: OFF" ;;
com.trimui.quiet.sh) MSG="Quiet: $STATE" ;;
com.trimui.silent.sh) MSG="Silent: $STATE" ;;
com.trimui.joystick.sh|com.trimui.toggle.dpad_joystick.sh) MSG="Joystick: $STATE" ;;
*) MSG="$STATE" ;;
esac

VOL_MSG_JSON="\n\
{ \n\
\"type\":\"default\", \n\
\"id\":\"com.trimui.osd.msg.fneditor_dip\", \n\
\"duration\":1000, \n\
\"size\":0, \n\
\"x\":700, \n\
\"y\":80, \n\
\"w\":300, \n\
\"h\":80, \n\
\"message\":\" $MSG\", \n\
\"font\":\"\", \n\
\"bg\":\"\", \n\
\"icon\":\"/usr/trimui/apps/fn_editor/ic-fn-on-tips.png\", \n\
\"fontsize\":24, \n\
\"fontcolor\":\"FF36FFA0\" \n\
} \n"

echo -e $VOL_MSG_JSON > /tmp/trimui_osd/osd_toast_msg
#echo -e $VOL_MSG_JSON > dump.txt
14 changes: 14 additions & 0 deletions spruce/scripts/platform/device_functions/Brick.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ init_gpio_a133p() {

device_init() {
device_init_a133p

# Show the configured switch action's name in the Fn switch popup instead
# of a generic ON/OFF. trimui_scened calls these popup scripts on every
# flip, so overlay our Brick-only versions with a bind mount.
FN_DIP_DIR="/usr/trimui/apps/fn_editor"
mount --bind /mnt/SDCARD/spruce/brick/fn_dip/show_fn_dip_on_msg.sh "${FN_DIP_DIR}/show_fn_dip_on_msg.sh" &
fn_dip_on_pid=$!
mount --bind /mnt/SDCARD/spruce/brick/fn_dip/show_fn_dip_off_msg.sh "${FN_DIP_DIR}/show_fn_dip_off_msg.sh" &
fn_dip_off_pid=$!
# Wait only for the two bind mounts, not a bare `wait`: device_init_a133p
# leaves fire-and-forget background jobs running (the startup-volume helper
# sleeps then blocks on sendevent), and a bare `wait` would hang boot on them.
wait "$fn_dip_on_pid" "$fn_dip_off_pid"

run_trimui_osdd

if [ ! -x /bin/bash ]; then
Expand Down