#!/bin/sh
#
# This is run as the user just logged in
#

PATH="/p/bin:/p/bin/X11:${PATH}"
EDITOR=/p/bin/emacs
VISUAL=$EDITOR
export EDITOR VISUAL
# Now again taken in /usr/ucb/man script
#MANPATH="/usr/man:/p/man"
#export PATH MANPATH

umask 022

case $# in
1)
	case $1 in
	failsafe)
		exec xterm -C -geometry 80x24+50+50 -title "Login -- Failsafe"
		;;
	F2)
		/p/src/dvorak/xdvorak >/dev/null 2>&1 # Switch to "Dvorak".
		;;
	esac
esac

case "$DISPLAY" in
  *.hut.fi:*) ;;	# Don't overwrite if it has full name already
  *)	DISPLAY="`hostname`:0"
esac
HOSTTYPE="`arch`"
export DISPLAY HOSTTYPE

startup=$HOME/.Xsession
defstartup=/p/etc/xdm/default-Xsession
resources=$HOME/.Xresources
myresources=$HOME/.myXresources

if [ -r $resources ]; then		# Get base resources
	xrdb -load $resources
else
	xrdb -load /p/etc/xdm/default-Xresources
fi

if [ -r $myresources ]; then		# User's additional resources
	xrdb -merge $myresources
fi

if [ -f $startup ]; then		# Users whole session script
	if [ -x $startup ]; then
		exec $startup $1
	else
		exec /bin/sh $startup $1
	fi
fi

if [ -f $defstartup ]; then		# Users whole session script
	if [ -x $defstartup ]; then
		exec $defstartup $1
	else
		exec /bin/sh $defstartup $1
	fi
fi

exec xterm -C -geometry 80x24+50+50 -title "X startup failed -- get help"

# EOF

