Blame SOURCES/Xsession

e61737
#!/bin/bash
e61737
# Copyright (C) 1999 - 2004 Red Hat, Inc. All rights reserved. This
e61737
# copyrighted material is made available to anyone wishing to use, modify,
e61737
# copy, or redistribute it subject to the terms and conditions of the
e61737
# GNU General Public License version 2.
e61737
#
e61737
# You should have received a copy of the GNU General Public License
e61737
# along with this program; if not, write to the Free Software
e61737
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
e61737
e61737
# redirect errors to a file in user's home directory if we can
e61737
if [ -z "$GDMSESSION" ]; then
e61737
    # GDM redirect output itself in a smarter fashion
e61737
    errfile="$HOME/.xsession-errors"
e61737
    if ( umask 077 && cp /dev/null "$errfile" 2> /dev/null ); then
e61737
        chmod 600 "$errfile"
e61737
        [ -x /sbin/restorecon ] && /sbin/restorecon $errfile
e61737
        exec > "$errfile" 2>&1
e61737
    else
e61737
        errfile=$(mktemp -q /tmp/xses-$USER.XXXXXX)
e61737
        if [ $? -eq 0 ]; then
e61737
            exec > "$errfile" 2>&1
e61737
        fi
e61737
    fi
e61737
fi
e61737
e61737
SWITCHDESKPATH=/usr/share/switchdesk
e61737
e61737
# Mandatorily source xinitrc-common, which is common code shared between the
e61737
# Xsession and xinitrc scripts which has been factored out to avoid duplication
e61737
. /etc/X11/xinit/xinitrc-common
e61737
e61737
# This Xsession.d implementation, is intended to obsolete and replace the
e61737
# various mechanisms present in the 'case' statement which follows, and to
e61737
# eventually be able to easily remove all hard coded window manager specific
e61737
# content from this script.  See bug #142260 for additional explanation and
e61737
# details.  All window manager rpm packages and desktop environment
e61737
# packages should be modified to provide the Xsession.d/Xsession.$wm scripts
e61737
# to start themselves up.  In the future, the legacy switchdesk mechanisms
e61737
# and hard coded window managers and desktop environments will be removed from
e61737
# this script. 
e61737
XCLIENTS_D=/etc/X11/xinit/Xclients.d
e61737
if [ "$#" -eq 1 ] && [ -x "$XCLIENTS_D/Xclients.$1.sh" ]; then
e61737
    exec -l $SHELL -c "$CK_XINIT_SESSION $SSH_AGENT $XCLIENTS_D/Xclients.$1.sh"
e61737
else
e61737
# now, we see if xdm/gdm/kdm has asked for a specific environment
e61737
case $# in
e61737
1)
e61737
    if [ -x "$SWITCHDESKPATH/Xclients.$1" ]; then
e61737
       exec -l $SHELL -c "$SWITCHDESKPATH/Xclients.$1";
e61737
    fi;
e61737
e61737
    case "$1" in
e61737
	failsafe)
e61737
	    exec -l $SHELL -c "xterm -geometry 80x24-0-0"
e61737
	    ;;
e61737
	gnome|gnome-session)
e61737
	    # lack of SSH_AGENT is intentional, see #441123.  though
e61737
	    # the whole thing should really happen in xinitrc.d anyway.
e61737
	    exec -l $SHELL -c gnome-session
e61737
	    exec /bin/sh -c "exec -l $SHELL -c \"gnome-session\"" 
e61737
	    ;;
e61737
	kde|kde1|kde2)
e61737
	    exec $CK_XINIT_SESSION $SSH_AGENT /bin/sh -c "exec -l $SHELL -c \"startkde\""
e61737
	    ;;
e61737
	twm)
e61737
        # fall back to twm
e61737
	    exec $CK_XINIT_SESSION $SSH_AGENT /bin/sh -c "exec -l $SHELL -c \"twm\""
e61737
	    ;;
e61737
	*)
e61737
       # GDM provies either a command line as the first argument or
e61737
       # provides 'failsafe', 'default' or 'custom'.  KDM will do the
e61737
       # same at some point
e61737
	    if [ "$1" != "default" -a "$1" != "custom" ]; then
e61737
		exec $CK_XINIT_SESSION $SSH_AGENT /bin/sh -c "exec -l $SHELL -c \"$1\""
e61737
	    fi
e61737
	    ;;
e61737
    esac
e61737
esac
e61737
fi
e61737
e61737
# otherwise, take default action
e61737
if [ -x "$HOME/.xsession" ]; then
e61737
    exec -l $SHELL -c "$CK_XINIT_SESSION $SSH_AGENT $HOME/.xsession"
e61737
elif [ -x "$HOME/.Xclients" ]; then
e61737
    exec -l $SHELL -c "$CK_XINIT_SESSION $SSH_AGENT $HOME/.Xclients"
e61737
elif [ -x /etc/X11/xinit/Xclients ]; then
e61737
    exec -l $SHELL -c "$CK_XINIT_SESSION $SSH_AGENT /etc/X11/xinit/Xclients"
e61737
else
e61737
    # should never get here; failsafe fallback
e61737
    exec -l $SHELL -c "xsm"
e61737
fi
e61737