Skip to content

Commit

Permalink
Add example init script
Browse files Browse the repository at this point in the history
  • Loading branch information
mthuurne committed Sep 22, 2014
1 parent 1262def commit 5de6e76
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ The getvolume utility was originally written by Yu-Jie Lin:
It was adopted by OpenDingux to save the current volume setting on system shutdown. A setvolume utility was added to restore the volume on boot.

You can pass "default" as the device name in most cases. Typical control names are "PCM" or "Master"; these match the control names shown in alsamixer.

S90volume.sh is an example init script to save and restore volume. It was written for use in the BusyBox init system, but it should be easy to adapt to other script-based init systems.
26 changes: 26 additions & 0 deletions S90volume.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
#
# Simple script to load/store ALSA volume.
#

VOLUME_STATEFILE=/usr/local/etc/volume.state
VOLUME_DEVICE=default
VOLUME_CONTROL=PCM

case "$1" in
start)
if [ -f $VOLUME_STATEFILE ]; then
echo "Loading sound volume..."
/usr/bin/alsa-setvolume $VOLUME_DEVICE $VOLUME_CONTROL `cat $VOLUME_STATEFILE`
fi
;;
stop)
echo "Storing sound volume..."
/usr/bin/alsa-getvolume $VOLUME_DEVICE $VOLUME_CONTROL > $VOLUME_STATEFILE
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac

exit $?

0 comments on commit 5de6e76

Please sign in to comment.