Blame SOURCES/Xsession

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