#!/bin/sh

##KDE3.5 KMix Button-Control by freezy.cz
## Create KMenu items or Desktop entries with following commands:
## for Increase volume: <path>/setkmix.sh up
## for Decrease volume: <path>/setkmix.sh down
## for Set a nominal volume (0~100): <path>/setkmix.sh NUMBER
## for Mute / Unmute master channel: <path>/setkmix.sh mute
## for Display OSD with current volume level: <path>/setkmix.sh vol

##If you want display OSD messages, you need to install "xosd-bin" package and uncomment lines containing strings "OSD" and "$OSD"!

export DISPLAY=':0'
VOL=$(dcop kmix Mixer0 masterVolume)
JUMP="5" ##set jump for parameters up and down
#OSD="osd_cat -o 20 -i 20 -A right -c green -d 1 -f -*-lucida-bold-r-*-*-34-*-*-*-*-*-*-*" ##uncomment this line to enable OSD

if [ "$1" == "down" ]
then
dcop kmix Mixer0 setMasterVolume $(($VOL-$JUMP))

#echo "Volume: $(dcop kmix Mixer0 masterVolume) %" |$OSD ##uncomment this line to enable OSD

elif [ "$1" == "up" ]
then
dcop kmix Mixer0 setMasterVolume $(($VOL+$JUMP))

#echo "Volume: $(dcop kmix Mixer0 masterVolume) %" |$OSD ##uncomment this line to enable OSD

elif [ "$1" == "mute" ]
then
dcop kmix Mixer0 toggleMasterMute

##uncomment following lines to enable OSD
#MUTE=$(dcop kmix Mixer0 masterMute)
#if [ $MUTE == "true" ]
#then
#echo "Mute ON" |$OSD
#elif [ $MUTE == "false" ]
#then
#echo "Mute OFF" |$OSD
#fi


elif [ "$1" == "vol" ] || [ "$1" = "" ]
then
echo "Current volume level: $VOL"

#echo "Volume: $VOL %" |$OSD ##uncomment this line to enable OSD

else
dcop kmix Mixer0 setMasterVolume $1

#echo "Volume: $(dcop kmix Mixer0 masterVolume) %" |$OSD ##uncomment this line to enable OSD

fi

