volcontrol
volcontrol is just a small shell script I wrote for my Acer Aspire 1300. I wanted to be able to use the volumecontrol keys on the keyboard so that it gave me feedback via an osd. I also wanted the mute button to automatically restore the old volume if it was pressed a second time, so that it unmutes the laptop. Please do not comment on poor code, this is my first a little bit more complex shellscript ever ;) Currently, I use the script in combination with mapped keys and the Fluxbox keymapper.
volcontrol
#!/bin/sh ############################################################### # volcontrol.sh # by Gina 'foosel' Haeussge # ------------------------------------------------------------- # Usage # volcontrol.sh mute|volup|voldown # # mute: # toggle muted / not muted, by restoring the volume to it's # original value # leaves state on OSD # # volup: # turns up the volume 5% # shows state on OSD # # voldown: # turns down the volume 5% # shows state on OSD ############################################################### OSD_FONT="-adobe-courier-bold-r-*-*-34-*-*-*-*-*-*-*" TMP_PATH=~/.scripts/oldvolume case "$1" in mute) if [ -f `echo $TMP_PATH` ] then # sound is muted by mutebutton.sh -> restore old volume aumix -v `cat $TMP_PATH` rm $TMP_PATH echo MUTE: off | osd_cat -f $OSD_FONT -s 1 -d 2 -o 10 -p bottom -c green else # sound is currently on user specified level -> backup old # values and mute VOLUME=`aumix -v q 2>/dev/null | awk {'print $2'}` CURVOLUME=${VOLUME:0:${#VOLUME}-1} echo "$CURVOLUME" > $TMP_PATH aumix -v 0 echo MUTE: on | osd_cat -f $OSD_FONT -s 1 -d 2 -o 10 -p bottom -c green fi ;; volup) if [ -f $TMP_PATH ] then rm $TMP_PATH fi `aumix -v +5` VOLUME=`aumix -v q 2>/dev/null | awk {'print $2'}` CURVOLUME=${VOLUME:0:${#VOLUME}-1} i=0 let "pipecount=$CURVOLUME / 5" while (($i < $pipecount)) do bar=${bar}"|" let "i += 1" done while (($i < 20)) do bar=${bar}"-" let "i += 1" done echo VOLUME: $bar $CURVOLUME % | osd_cat -f $OSD_FONT -s 1 -d 2 -o 10 -p bottom -c green ;; voldown) if [ -f $TMP_PATH ] then rm $TMP_PATH fi `aumix -v -5` VOLUME=`aumix -v q 2>/dev/null | awk {'print $2'}` CURVOLUME=${VOLUME:0:${#VOLUME}-1} i=0 let "pipecount=$CURVOLUME / 5" while (($i < $pipecount)) do bar=${bar}"|" let "i += 1" done while (($i < 20)) do bar=${bar}"-" let "i += 1" done echo VOLUME: $bar $CURVOLUME % | osd_cat -f $OSD_FONT -s 1 -d 2 -o 10 -p bottom -c green ;; esac
A download is available here.
To use volcontrol, you need to have aumix and xosd installed.




