Thursday, March 31, 2005

Volume controls

Now have volume keybinding in place. Thanks to Timo(http://www.jroller.com/page/timsu/20050215), updated script is below.
Needed to emerge xosd (already had aumix on the system), this script will work for xosd 2.2.8-14.

audio_adjust.sh:

#!/bin/sh

cd $HOME

action=$1; shift
killall -q osd_cat > /dev/null 2>&1

get_volume() {
volume=`aumix -q | sed -ne 's/^vol \([^,]*\).*/\1/p'`
}

show_volume() {
#echo Volume:\ $1|osd_cat -o 300 -A center -c green -s 10
osd_cat --text Volume:\ $1 --barmode=percentage --percentage=$1 -o 300 -A center -c green -s 10
}

case "$action" in

incr)
delta=${1:-5}
rm -f .mutevol
aumix -v +$delta
get_volume
show_volume $volume
;;

decr)
delta=${1:-5}
rm -f .mutevol
aumix -v -$delta
get_volume
show_volume $volume
;;

mute)
if [ -s .mutevol ]
then
vol=`cat .mutevol`
rm -f .mutevol
aumix -v $vol
# echo "Volume: $vol" | xosd -- -
show_volume $vol
else
get_volume
[ $volume != 0 ] && echo $volume > .mutevol
aumix -v 0
echo "Volume: muted" | xosd -- -
fi
;;
esac


.xbindkeysrc entry:
"~/bin/audiomix.sh incr"
c:86 + m:0x4
"~/bin/audiomix.sh decr"
c:82 + m:0x4

No comments: