ossvol
a simple oss volume manager
You are here › Source

ossvol is open source... see?

For those of you who would rather take a look under the hood than actually install it, here's the source!

May the source be with you!

#!/bin/bash # # ossvol is a simple script to manage oss volume levels and muting. # Script by: Daniel J Griffiths # Configure stuff VOLSTORE=~/.volume CHANNEL="vol" ARGUMENT=$2 # You shouldn't have to edit below here. err() { echo "$1" exit 1 } usage() { echo "usage: ossvol [option] [argument]" echo echo "Options:" echo " -i, --increase - increase volume by [argument]" echo " -d, --decrease - decrease volume by [argument]" echo " -t, --toggle - toggle mute on and off" echo " -h, --help - display this" exit } toggle() { if [ -f $VOLSTORE ]; then ossmix $CHANNEL `cat $VOLSTORE` rm $VOLSTORE else VOLUME=$(ossmix $CHANNEL | awk '{print $10}' | awk -F : '{print $1}') ossmix $CHANNEL 0 echo $VOLUME > $VOLSTORE fi } increase() { if [ -f $VOLSTORE ]; then TMPVOL=`cat $VOLSTORE` NEWVOL=`expr $TMPVOL + $ARGUMENT` ossmix $CHANNEL +$NEWVOL rm $VOLSTORE else ossmix $CHANNEL +$ARGUMENT fi } decrease() { if [ -f $VOLSTORE ]; then TMPVOL=`cat $VOLSTORE` NEWVOL=`expr $TMPVOL - $ARGUMENT` ossmix $CHANNEL -- -$NEWVOL rm $VOLSTORE else ossmix $CHANNEL -- -$ARGUMENT fi } case "$1" in '-i'|'--increase') increase ;; '-d'|'--decrease') decrease ;; '-t'|'--toggle') toggle ;; ''|'-h'|'--help') usage ;; *) err "Unrecognized option \`$1', see ossvol --help" ;; esac