rgnano: Instant play support and proper system brightness/volume handling

Instant play is a Funkey OS feature that allows it to relaunch at boot the last program it was running before shutting down, which means that if the handheld is powered off (holding the power button) while rockbox is running the next time it's powered on rockbox will launch at boot.

This commit also handles system brightness/volume in rockbox itself instead of the launch script, so the values are properly reset when powering off the handheld while rockbox is running.

Change-Id: Ie1adbf71069aeed5fbf6670971718a2f718716a3
This commit is contained in:
Hairo R. Carela 2025-08-05 22:56:17 -04:00 committed by Solomon Peachy
parent 16a6ad032f
commit 46d10dda33
5 changed files with 167 additions and 7 deletions

View file

@ -4,6 +4,11 @@ RBDIR=/mnt/FunKey/rockbox
CFGFILE=$RBDIR/config.cfg
BLPATH=/sys/class/backlight/backlight/brightness
_send_sigusr1()
{
kill -s USR1 "$rb_pid" 2>/dev/null
}
# Install the rockbox folder
if [ ! -d $RBDIR ]; then
notif set 0 " Installing rockbox..."
@ -27,12 +32,13 @@ if [ ! -f $CFGFILE ]; then
cp ./config.cfg $CFGFILE
fi
# Get current volume/brightness -> launch rockbox -> restore previous values
CUR_VOL=$(volume get)
CUR_BL=$(cat $BLPATH)
volume set 100
# Set volume to max with amixer so it's not permanent
amixer -q sset 'Headphone' 63 unmute
./rockbox
# Need to send SIGUSR1 to the rockbox process for instant play support
trap _send_sigusr1 SIGUSR1
volume set $CUR_VOL
echo $CUR_BL > $BLPATH
./rockbox &
rb_pid=$!
wait "$rb_pid"