#!/bin/sh
# 

killproc() {            # kill the named process(es)
        pid=`/bin/ps -e |
             /bin/grep $1 |
             /bin/sed -e 's/^  *//' -e 's/ .*//'`
        [ "$pid" != "" ] && kill $pid
}
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/bin/X11:/usr/local/bin:/usr/local/cps/bin
export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/lib/X11:/usr/local/lib
export DISPLAY=unix:0
export USER=root
export HOME=/root
export XAPPLRESDIR=/usr/lib/X11/app-defaults
export XFILESEARCHPATH=./%N%S%C.ad:/usr/X11R6/lib/X11/%L/%T/%N%S%C:/usr/X11R6/lib/X11/%l/%T/%N%S%C:/usr/X11R6/lib/X11/%T/%N%S%C:./%N%S.ad:/usr/X11R6/lib/X11/%L/%T/%N%S:/usr/X11R6/lib/X11/%l/%T/%N%S:/usr/X11R6/lib/X11/%T/%N%S:/usr/local/lib/X11/app-defaults/%N%S%C.ad

case $1 in
'start')
	if [ -r /usr/bin/X11/Xfbdev ]
	then
		echo "Starting X demonstration"
		cd /usr/bin/X11
		## -dumbSched to workaround 2.4.0 scheduler bug
		./Xfbdev -screen 240x320 -screen 320x240 +xinerama &
		sleep 3
#clock first, or the server will reset and Xdefault resources will get forgotton
		./oclock -geom =75x75+0-0 -transparent -fg white -bg black -bd white&
		sleep 3
		./twm -f /etc/init.d/twmrc &
		./xset s 30 180
		./bl 1 1 32
# xrdb has to be used -nocpp since there is no c preprocessor on an Itsy or iPAQ
		./xrdb -load -nocpp < /usr/lib/X11/Xdefaults
#calibrate the touch screen 
#               ./xcalibrate
# xsetitsy
		./xsetroot -solid blue &
		./xscribble -geom =+140+0&
	fi
        ;;
'stop')
        echo "Killing X server"
        killproc Xfbdev
        ;;
*)
        echo "usage: $0 { start | stop }"
        ;;
esac
