#!/bin/sh
#
# Runs the user's .xinitrc (at this point, .xsession has already
# been sourced). If there is no .xinitrc, but xinit is installed,
# then there is a default script. If neither is installed,
# display a message.

RC="$HOME/.xinitrc"
if [ ! -f "$RC" ] ; then
	RC="/usr/local/etc/X11/xinit/xinitrc"
	# But that one needs at least xterm to do something useful
	if [ ! -x /usr/local/bin/xterm ] ; then
		RC=""
	fi
fi

if [ -n "$RC" -a -f "$RC" ] ; then
	test -x "$RC" && exec "$RC"
	test -f "$RC" && exec /bin/sh "$RC"
else
	exec /usr/local/bin/xmessage -geometry +0+0 "There is no user-session or usable default with xterm"
fi
