#!/bin/sh
-# Copyright (c) 1999, 2000 Red Hat, Inc.
-# redirect errors to a file in user's home directory if we can
-for errfile in "${TMPDIR-/tmp}/.xsession-$USER" \
- "/tmp/.xsession-$USER" \
- "$HOME/.xsession-errors"
-do
- if cp /dev/null "$errfile" 2> /dev/null ; then
- chmod 600 "$errfile"
- exec > "$errfile" 2>&1
- break
- fi
-done
-
-[ "`echo $PATH | grep -q /usr/X11R6/bin`" = "" ] && PATH="${PATH}:/usr/X11R6/bin"
-[ "`echo $PATH | grep -q "$HOME/bin"`" = "" ] && PATH="$PATH:$HOME/bin"
-
-test -f /etc/profile && . /etc/profile
-test -f $HOME/.profile && . $HOME/.profile
-
-if [ ! -f $HOME/.profile ] && echo $SHELL |grep -q "bash"; then
- test -f $HOME/.bash_profile && . $HOME/.bash_profile
-fi
-
-userresources=$HOME/.Xresources
-usermodmap=$HOME/.Xmodmap
-userxkbmap=$HOME/.Xkbmap
-
-sysresources=/etc/X11/Xresources
-sysmodmap=/etc/X11/Xmodmap
-sysxkbmap=/etc/X11/Xkbmap
-
-# merge in defaults
-[ -f "$sysresources" ] && xrdb -merge "$sysresources"
-[ -f "$userresources" ] && xrdb -merge "$userresources"
-
-# merge in keymaps
-if [ -f "$sysxkbmap" ]; then
- setxkbmap `cat "$sysxkbmap"`
- XKB_IN_USE=yes
+# Make it login shell
+if [ "$HAVE_LOGIN_SHELL" != "yes" ]; then
+ export HAVE_LOGIN_SHELL=yes
+ case $SHELL in
+ */csh|*/tcsh)
+ # [t]cshrc is always sourced automatically.
+ # Note that sourcing csh.login after .cshrc is non-standard.
+ exec $SHELL -c "if (-f /etc/csh.login) source /etc/csh.login; if (-f ~/.login) source ~/.login; exec $0 $*"
+ ;;
+ *)
+ exec $SHELL -l $0 $*
+ esac
fi
+unset HAVE_LOGIN_SHELL
-if [ -f "$userxkbmap" ]; then
- setxkbmap `cat "$userxkbmap"`
- XKB_IN_USE=yes
-fi
+# Call standard xinit actions
+. /etc/X11/xinit/xinitdefs
-if [ -z "$XKB_IN_USE" -a ! -L /etc/X11/X ]; then
- if grep '^exec.*/Xsun' /etc/X11/X > /dev/null 2>&1 \
- && [ -f /etc/X11/XF86Config ]; then
- xkbsymbols=`sed -n -e 's/^[ ]*XkbSymbols[ ]*"\(.*\)".*$/\1/p' /etc/X11/XF86Config`
- if [ -n "$xkbsymbols" ]; then
- setxkbmap -symbols "$xkbsymbols"
- XKB_IN_USE=yes
- fi
- fi
-fi
-
-# xkb and xmodmap don't play nice together
-if [ -z "$XKB_IN_USE" ]; then
- [ -f "$sysmodmap" ] && xmodmap "$sysmodmap"
- [ -f "$usermodmap" ] && xmodmap "$usermodmap"
-fi
-
-unset XKB_IN_USE
-
-# run all system xinitrc shell scripts.
-for i in /etc/X11/xinit/xinitrc.d/* ; do
- if [ -x "$i" ]; then
- . "$i"
- fi
-done
-
-# exec specified session or tell user if not found
-loadsess()
-{
- [ `/usr/bin/which $sess` ] && exec $sess || exec xmessage -center -buttons OK:0 \
- -default OK "Sorry, $sess not found."
-}
-
-# now, we see if xdm/gdm/kdm has asked for a specific environment
case $1 in
failsafe)
exec xterm -geometry 80x24-0-0
;;
- gnome)
- sess=gnome-session
- loadsess
- ;;
- kde)
- sess=startkde
- loadsess
- ;;
- windowmaker)
- sess=wmaker
- loadsess
- ;;
- xfce)
- sess=startxfce
- loadsess
- ;;
""|default)
# take default action
- if [ -f "$HOME/.xsession" ]; then
- exec "$HOME/.xsession"
- elif [ -f "$HOME/.Xclients" ]; then
+ if [ -x "$HOME/.Xclients" ]; then
exec "$HOME/.Xclients"
else
exec /etc/X11/xinit/Xclients
fi
;;
- *)
- sess=$*
- if [ -f "$HOME/bin/$sess.sh" ]; then
- exec "$HOME/bin/$sess.sh"
+ custom)
+ if [ -x "$HOME/.xsession" ]; then
+ exec "$HOME/.xsession"
else
- loadsess
- fi
- ;;
+ exec xmessage -center -buttons OK:0 -default OK \
+ "Sorry, $HOME/.xsession not found."
+ fi
+ ;;
+ *)
+ exec /etc/X11/xinit/Xclients $1
esac