Skip to content
Open
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
30 changes: 16 additions & 14 deletions board/opendingux/gcw0/overlay/etc/init.d/S90volume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
#

VOLUME_STATEFILE=/usr/local/etc/volume.state
CONTROL=PCM

case "$1" in
start)
echo "Loading sound volume..."
if [ -f $VOLUME_STATEFILE ]; then
/usr/bin/amixer set $CONTROL `cat $VOLUME_STATEFILE`
fi
;;
stop)
echo "Storing sound volume..."
amixer get $CONTROL | sed -n 's/.*Front .*: Playback \([0-9]*\).*$/\1/p' | paste -d "," - - > $VOLUME_STATEFILE
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
start)
echo "Loading sound volume..."
if [ -f $VOLUME_STATEFILE ]; then
/usr/bin/amixer set PCM `head -1 $VOLUME_STATEFILE`
/usr/bin/amixer set Headphones `head -2 $VOLUME_STATEFILE`
fi
;;
stop)
echo "Storing sound volume..."
PCM_VOL=`amixer get PCM | sed -n 's/.*Front .*: Playback \([0-9]*\).*$/\1/p' | paste -d "," - -`
HP_VOL=`amixer get Headphones | sed -n 's/.*Front .*: Playback \([0-9]*\).*$/\1/p' | paste -d "," - -`
printf "$PCM_VOL\n$HP_VOL\n" > $VOLUME_STATEFILE
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac

exit $?