#!/bin/bash # this version works with ALSA. hacked out on debian/woody, but # should work anywhere. function read_volume() { #aumix-minimal -vq | cut -d\ -f 3 setmixer -V | grep "vol" | cut -d \- -f 2 | cut -d , -f 1 } VOLUME=`read_volume` echo "LABEL Volume($VOLUME%)" echo "LABEL_UP +" echo "LABEL_DOWN -" echo "OK" read press echo "OK" while read cmd arg; do case $cmd in PRESS) exit 0;; TURN) VOLUME=`expr $VOLUME + $arg \* 10` if [ $VOLUME -lt 0 ]; then VOLUME=0; echo "LABEL_DOWN "; fi if [ $VOLUME -gt 100 ]; then VOLUME=100; echo "LABEL_UP "; fi #aumix-minimal -v$VOLUME setmixer vol $VOLUME # percentage gets scaled to a number 0-31, so we read_volume # again to get the actual percentage. VOLUME=`read_volume` # it's possible to read/set on the 0-31 scale, but % is more # intuitive. 32 steps is a lot of wheel-spinning, # and probably more fine-grained than is useful. echo "LABEL Volume($VOLUME%)" echo "OK" ;; esac done