#!/bin/bash

if [ $1 ];
then
	if [ $1 == "volUp" ];
	then
		CURRENT_VOLUME=`qdbus org.mpris.amarok /Player VolumeGet`
		NEW_VOLUME=`expr $CURRENT_VOLUME + 8`
		`qdbus org.mpris.amarok /Player VolumeSet $NEW_VOLUME`
	elif [ $1 == "volDown" ];
	then
		CURRENT_VOLUME=`qdbus org.mpris.amarok /Player VolumeGet`
		NEW_VOLUME=`expr $CURRENT_VOLUME - 8`
		`qdbus org.mpris.amarok /Player VolumeSet $NEW_VOLUME`
	elif [ $1 == "seekUp" ];
	then
		CURRENT_POS=`qdbus org.mpris.amarok /Player PositionGet`
		NEW_POS=`expr $CURRENT_POS + 2000`
		`qdbus org.mpris.amarok /Player PositionSet $NEW_POS`
	elif [ $i == "seekDown" ];
	then
		CURRENT_POS=`qdbus org.mpris.amarok /Player PositionGet`
		NEW_POS=`expr $CURRENT_POS - 2000`
		`qdbus org.mpris.amarok /Player PositionSet $NEW_POS`
	fi
else
	if [ `ps aux | grep "irexec --name amarok" | grep -v "grep" | wc -l` -le 0 ]
	then
		echo "Starting irexec"
		if [ ! -f "$HOME/.lirc/amarok" ];
		then
			echo "ERROR: $HOME/.lirc/amarok does not exist"
			exit
		else
			IREXEC_ARGS="--name amarok -d $HOME/.lirc/amarok"
			`env irexec $IREXEC_ARGS`

		fi
	else
		echo "Already running"
	fi
fi



