#!/bin/sh

# sqp_JogglerAudio.sh v1.00 (20th April 2012) by Andy Davison
#  Called by the JogglerAudio applet to mess with the Jogglers audio settings.

PLATFORM=`cat /tmp/sqp_platform`
[ "$PLATFORM" = "native" ] || export PATH=$PATH:`dirname $0`

if [ "$1" = "" ]; then
	echo "Usage: $0 <option> <action>"
	exit 0
fi

if [ "$PLATFORM" = "native" ]; then
	INSTALL_DIR="/media/opt"
	SUDO=""
else
	INSTALL_DIR="/opt"
	SUDO="sudo"
fi

## Swapping the asound.conf files.
if [ "$1" = "mixer" ]; then
	if [ "$2" = "" ]; then
		echo "Usage: $0 $1 <simple|mixer>"
		exit 0
	else
		if [ -f $INSTALL_DIR/squeezeplay/config/asound.conf_$2 ]; then
			$SUDO cp $INSTALL_DIR/squeezeplay/config/asound.conf_$2 /etc/asound.conf
		else
			echo "The asound.conf file 'config/asound.conf_$2' has not been found."
			exit 0
		fi
	fi
fi

exit 0