#!/bin/bash # config vars - set them appropriate to your system specs NUM="2" #find with: amixer controls DEVICE="Master Playback" #just call amixer STANDARDVOLUME="80%" #you can also use dB values AMIXER=amixer AUDIOPLAY=aplay #any other audioplayer should do the job, too AUDIOFILE=~/hae.wav ################# don't change anything below here ############################# #check whether we get the volume from commandline if [ $# -eq 1 ] then VOLUME=$1 else VOLUME=${STANDARDVOLUME} fi #get the current volume OLD_VOLUME=$(amixer cget numid=$NUM | grep :) OLD_VOLUME=${OLD_VOLUME#*=} #set the desired volume ${AMIXER} sset $DEVICE $VOLUME &> /dev/null #play the audiofile ${AUDIOPLAY} ${AUDIOFILE} &> /dev/null #restore the old volume ${AMIXER} sset $DEVICE $OLD_VOLUME &> /dev/null