#!/bin/sh
#Nice way of starting X
#By James Stanley

client="$1"
display=$2

#Set default client
if [ "$1" == "" ]
then
		client="blackbox"
fi

#See if an (executable!) init script exists
#Due to (what I can only assume is) a bug in bash, the file name can't have
#double quotes around it. This means that if anyone wants to run a client with
#a space in it, they're out of luck
if [ -x ~/.xinitrc.$client ]
then
		client=~/.xinitrc.$client
else
		client=`which $client`
fi

#Find an unused display
if [ "$2" == "" ]
then
		display=0
		while [ -e "/tmp/.X${display}-lock" ]
		do
				display=$((display+1))
		done
fi

echo $client

#And run xinit
xinit "$client" -- ":$display"
