#!/bin/sh

# User can specify his volume control by settings DEFVC variable

# default-wm value
DEFVC=

#read in the arguments
GET=
for n in "$@" ; do
  case "$GET" in
    defwm)
      DEFWM=$n
      GET=
      ;;
    *)
      case "$n" in
        --default-vc)
          GET=defvc
          ;;
      esac
      ;;
  esac
done

# VOLUME_CONTROL overrides all
if [ -z "$VOLUME_CONTROL" ] ; then
	VOLUME_CONTROL=$(gconftool-2 --get /apps/gnome-volume-control/rh/volume_control)
fi

# If no volume control can be found, we default to GNOME's tool

if [ -z "$VOLUME_CONTROL" ] ; then
  echo "WARNING: No volume control can be found."
  VOLUME_CONTROL=gnome-volume-control.real
fi

case "$VOLUME_CONTROL" in 
	pavucontrol)
	 exec pavucontrol
	;;
	gnome-volume-control)
	 exec gnome-volume-control.real
	;;
esac

echo "ERROR: No volume control could run!"
