#!/bin/sh
# Start/stop the i8kbuttons daemon.

test -f /usr/bin/i8kbuttons || exit 0
test -f /usr/bin/aumix || exit 0

case "$1" in
start)	echo -n "Starting volume button daemon: i8kbuttons"
	/sbin/modprobe i8k
        start-stop-daemon --start --quiet --chuid nobody:audio --background \
		--exec /usr/bin/i8kbuttons \
		-- -u "/usr/bin/aumix -v +10" -d "/usr/bin/aumix -v -10" \
		   -m "/usr/bin/aumix -v 0" -r 100
        echo "." 
	;;
stop)	echo -n "Stopping volume button daemon: i8kbuttons"
        start-stop-daemon --stop --quiet --exec /usr/bin/i8kbuttons
        echo "."
        ;;
restart) echo -n "Restarting volume button daemon: i8kbuttons"
        start-stop-daemon --stop --quiet --exec /usr/bin/i8kbuttons
        start-stop-daemon --start --quiet --chuid nobody:audio --background \
		--exec /usr/bin/i8kbuttons \
		-- -u "/usr/bin/aumix -v +10" -d "/usr/bin/aumix -v -10" \
		   -m "/usr/bin/aumix -v 0" -r 100
        echo "."
        ;;
*)	echo "Usage: /etc/init.d/i8kbuttons start|stop|restart"
        exit 1 
        ;;
esac
exit 0
