You are not logged in.

#!/bin/bash
 
        vol_step="0.5"
 
  volnow_command="ossmix -d0 vmix0-outvol"
   volup_command="ossmix -d0 vmix0-outvol -- +"$vol_step
 voldown_command="ossmix -d0 vmix0-outvol -- -"$vol_step
 volmute_command="ossmix -d0 vmix0-outvol -- 0"
  volset_command="ossmix -d0 vmix0-outvol -- "
  notify_command="notify-send -t 500 -i "
function set_icon {
 
 speaker_icon="/usr/share/icons/gnome/256x256/status/audio-volume-"
 if   [ $volnow -eq 0   ]; then speaker_icon=$speaker_icon"muted.png "
 elif [ $volnow -lt 25  ]; then speaker_icon=$speaker_icon"low.png "
 elif [ $volnow -lt 75  ]; then speaker_icon=$speaker_icon"medium.png "
 elif [ $volnow -le 100 ]; then speaker_icon=$speaker_icon"high.png "
 fi
}
function vol_now { volnow=$(($($volnow_command | awk '{print $10}' | sed 's/\.//')*10/25)); } # i cant achieve unification
function vol_mute { 
 
 if [ -e ~/.vol.mute ]; then
  ${volset_command}$(cat ~/.vol.mute); rm ~/.vol.mute
 else
  echo $($volnow_command | awk '{print $10}') > ~/.vol.mute; $volmute_command
 fi
 
} # i cant achieve unification
case $1 in
 
  now) vol_now; echo $volnow;;
   
   up)   $volup_command; [ -e ~/.vol.mute ] && rm ~/.vol.mute;;
 down) $voldown_command;;
 mute) vol_mute;;
    *) echo "$(basename $0) [now | up | down | mute [notify]]";; ## write usage description, if you want
esac
[ $# = "2" ] && [ $2 = "notify" ] && (vol_now; set_icon; notify_text=" Volume: <b>${volnow}%</b>"; ${notify_command}${speaker_icon}${notify_text})
exit 0Last edited by ResXaoC (2011-07-19 18:31:37)
Offline

any comments?
Offline

I would suggest you not to use variable to keep commands. For that, use functions!
My blog: blog.marcdeop.com
Jabber ID: damnshock@jabber.org
Offline