volume_control.sh
#!/bin/sh
### Volume Control Script
#
# cobbled together from some other scripts on the net by Garth Dahlstrom (ironstorm@users.sf.net) in 2005
# for use on an X1000 with KHotKeys (after setting the Keyboard Layout to HP Omnibook XE3 GF in Keyboard Layout)
#
# The script will try to use KMixer if it is available, otherwise it will fallback to aumix
#
# Usages:
# ./volume_control.sh [0] - mute/unmute
# ./volume_control.sh -5 - decrease volume by 5%
# ./volume_control.sh 5 - increase volume by 5%
#
## Make sure there is a volume adjustment either x or -x
if [ "$1" != "" ] && [ "$1" != "0" ]; then
echo 1 is $1
if [ `ps aux | grep kmix | grep -v grep | wc -l` -eq 1 ]; then
dcop kmix Mixer0 setVolume deviceidx `expr $(dcop kmix Mixer0 volume deviceidx) + $1`
else
aumix -v `expr $(aumix -q | grep vol | awk ' { print $2 }' | cut -d , -f 1) + $1`
fi
elif [ "$1" == "" ] || [ "$1" == "0" ]; then
## No adjustment or a 0 parameter will mute the volume
if [ `ps aux | grep kmix | grep -v grep | wc -l` -eq 1 ]; then
MLEVEL=`dcop kmix Mixer0 mute 0`
if [ $MLEVEL != "true" ]; then
dcop kmix Mixer0 setMute 0 true
else
dcop kmix Mixer0 setMute 0 false
fi
else
BACKUP=/tmp/aumix-unmute-settings
if [ `aumix -q | grep vol | awk ' { print $2 }' | cut -d , -f 1` -ne 0 ]; then
aumix -q | grep vol | awk ' { print $2 }' | cut -d , -f 1 > $BACKUP
aumix -v 0
else
if [ -f $BACKUP ]; then
aumix -v `cat $BACKUP`
else
aumix -v 30
fi
fi
fi
fi