#!/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="%%LOCALBASE%%/etc/X11/xinit/xinitrc"
	# But that one needs at least xterm to do something useful
	if [ ! -x %%LOCALBASE%%/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 %%LOCALBASE%%/bin/xmessage -geometry +0+0 "There is no user-session or usable default with xterm"
fi
