#!/bin/sh

# Run Accelemymote if it's installed and ~/.d1x-rebirth/amm-autostart exists
AMM_AUTOSTART=~/.d1x-rebirth/amm-autostart
AMM_EXECUTABLE=/opt/maemo/usr/bin/accelemymote
AMM_TRIGGER=/tmp/accelemymote-live
if [ -f $AMM_AUTOSTART ] && [ -x $AMM_EXECUTABLE ] && [ ! -f $AMM_TRIGGER ]; then
	touch $AMM_TRIGGER
	$AMM_EXECUTABLE &
	AMM_STARTED=1
else
	AMM_STARTED=0
fi

# Start D1X-Rebirth
/opt/d1x-rebirth/d1x-rebirth-gl -mouselook

# Close Accelemymote if we've started it
if [ $AMM_STARTED -eq 1 ]; then
	rm $AMM_TRIGGER
fi
