scripts

misc scripts and tools
git clone git://git.2f30.org/scripts.git
Log | Files | Refs

volume (587B)


      1 #!/bin/sh
      2 
      3 #OpenBSD volume control
      4 #normalizes the input percentage to 0-255
      5 printvol() {
      6         currval=$(mixerctl|grep outputs.master\=|awk -F"," '{print $NF}')
      7         currval=$(echo $currval "/ 2.55"|bc)
      8         echo "Current level:" $currval "%"
      9 }
     10 
     11 usageexit() {
     12 	typeset -i currval
     13 	echo "usage:" "$(basename $0) [0-100]"
     14 	printvol
     15 	exit
     16 }
     17 
     18 case $1 in
     19 	+([0-9]) )
     20 		if [  $1 -gt 100 -o $1 -lt 0 ]; then
     21 			usageexit
     22 		fi
     23 		typeset -i volvar
     24 		volvar=$(printf "%1.0f" $(echo  $1 "* 2.55" |bc))
     25 		mixerctl -n outputs.master=$volvar,$volvar
     26 		printvol
     27 		;;
     28 	*)
     29 		usageexit
     30 		;;
     31 esac