#!/bin/sh

# squeezeplay.sh v1.11 (25th March 2012) by Andy Davison
#  This is the SqueezePlay startup script.

## Determine our environment
if [ -f /etc/software.ver ]; then
	PLATFORM="native"
elif [ -f /etc/sqpos.ver ]; then
	PLATFORM="sqpos"
else
	PLATFORM=`lsb_release -sc`
	[ "$PLATFORM" = "" ] && PLATFORM="generic"
fi
echo $PLATFORM > /tmp/sqp_platform

## Set install path
if [ "$PLATFORM" = "native" ]; then
	INSTALL_DIR=/media/opt/squeezeplay
else
	INSTALL_DIR=/opt/squeezeplay
fi

## Environment variables
LIB_DIR=$INSTALL_DIR/lib
INC_DIR=$INSTALL_DIR/inc
export LD_LIBRARY_PATH=$LIB_DIR:$LD_LIBRARY_PATH
export LD_INCLUDE_PATH=$INC_DIR:$LD_INCLUDE_PATH
export PATH=$PATH:$INSTALL_DIR/bin
export DISPLAY=:0.0
export SDL_AUDIODRIVER=alsa
export KMP_DUPLICATE_LIB_OK=TRUE
export SDL_VIDEO_WINDOW_POS=0,0
export SDL_VIDEO_ALLOW_SCREENSAVER=1

## Startup
if [ "$PLATFORM" = "native" ]; then
	
	unset SDL_WINDOWID
	cd $INSTALL_DIR/bin
	./jive
	
elif [ "$PLATFORM" = "sqpos" ]; then

	cd $INSTALL_DIR/bin
	#./jive &> /var/log/squeezeplay.log &
	./jive
	
else
	
	killall gnome-power-manager
	cd $INSTALL_DIR/bin
	./togglepanel.sh hide
	#./jive &> /var/log/squeezeplay.log &
	./jive
	
fi
