Blame SOURCES/Xsession

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