#!/bin/sh 

#	Top level Xsession file for all users
#
#	$Header: /afs/rel-eng.athena.mit.edu/project/release/current/source/athena/etc.athena/xdm/conf/RCS/Xsession,v 1.5 91/03/28 12:46:48 mar Exp $
#	$Source: /afs/rel-eng.athena.mit.edu/project/release/current/source/athena/etc.athena/xdm/conf/RCS/Xsession,v $
#	$Author: mar $
#

trap '/usr/athena/bin/kdestroy; exit 0' 1 2 15

initlib="/usr/athena/lib/init"
athbin="/usr/athena/bin"
xbin="/usr/bin/X11"
defsession=$1
defsessioncmd="$2"

case $defsession in
1)
	if [ -f .xsession ]; then
		session=".xsession"
	else
		session="$initlib/xsession"
	fi
	;;
2)
	NOCALLS=1; export NOCALLS
	session="$initlib/xsession"
	;;
3)
	session="${xbin}/xterm -ls -geometry 80x24+280+220 -display :0.0"
	;;
4)
	session="$defsessioncmd"
	;;
esac

# Set the tty characteristics of the parent (console window)
# the redirection sets stdin the same as stdout instead of /dev/null
/bin/stty dec 0<&1
$session

status=$?
if [ $status != 0 ]; then
		echo ERROR:
		echo "Xsession returned non-zero status."
		echo ""
		echo 'Select the login option to "Ignore your customizations"'
		echo 'to login and repair your .xsession file.'
		${athbin}/kdestroy			# destroy tickets.
		sleep 10
		exit $status
fi


# Cannot detach homedir here, since this script is executed in the users
# homedir.

${athbin}/kdestroy			# destroy tickets.
sleep 3					# let them see any messages (quickly)
exit 0
