#!/bin/sh

export PATH=$PATH:./
perform ()
{
    if  [ "$TESTMODE" = "" ]
    then
	echo "execute!: $@"
	"$@"
    else
	echo "skip: $*"
    fi
}

mutter ()
{
    if [ "$NOISY" = "1" ]
    then
	echo "MSG: $*"
    fi
}


mutter "Altering X.ORG config.."

NOISY=""
TESTMODE="-t"
for i in $*
do
    if echo "$i" | grep "^-" > /dev/null
    then
	if echo "$i" | grep "v" > /dev/null	
	then
	    NOISY=1
	fi
	if echo "$i" | grep "t" > /dev/null	
	then
	    TESTMODE="-t"
	fi
	if echo "$i" | grep "x" > /dev/null	
	then
	    TESTMODE=""
	fi
    fi
done

perform alterxconfig.pl /etc/X11/xorg.conf deletesection "Touchscreen" deleteentry '"Touchscreen"' "*"

perform alterxconfig.pl /etc/X11/xorg.conf addsection touchscreen.section addentry 'ServerLayout' 'InputDevice "Touchscreen"'

mutter "Making sure the driver loads at boot.."
