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
GSESSION="$(type -p gnome-session)"
e61737
MSESSION="$(type -p mate-session)"
e61737
STARTKDE="$(type -p startkde)"
e61737
STARTLXDE="$(type -p startlxde)"
e61737
e61737
# check to see if the user has a preferred desktop
e61737
PREFERRED=
e61737
if [ -f /etc/sysconfig/desktop ]; then
e61737
    . /etc/sysconfig/desktop
e61737
    if [ "$DESKTOP" = "GNOME" ]; then
e61737
	PREFERRED="$GSESSION"
e61737
    elif [ "$DESKTOP" = "MATE" ]; then
e61737
	PREFERRED="$MSESSION"
e61737
    elif [ "$DESKTOP" = "KDE" ]; then
e61737
	PREFERRED="$STARTKDE"
e61737
    elif [ "$DESKTOP" = "LXDE" ]; then
e61737
	PREFERRED="$STARTLXDE"
e61737
    fi
e61737
fi
e61737
e61737
if [ -n "$PREFERRED" ]; then
e61737
    exec "$PREFERRED"
e61737
fi
e61737
e61737
# now if we can reach here, either no desktop file was present,
e61737
# or the desktop requested is not installed.
e61737
e61737
if [ -n "$GSESSION" ]; then
e61737
    # by default, we run GNOME.
e61737
    exec "$GSESSION"
e61737
elif [ -n "$STARTKDE" ]; then
e61737
    # if GNOME isn't installed, try KDE.
e61737
    exec "$STARTKDE"
e61737
elif [ -n "$STARTLXDE" ]; then
e61737
    # if neither GNOME nor KDE then LXDE
e61737
    exec "$STARTLXDE"
e61737
fi
e61737
e61737
# We should also support /etc/X11/xinit/Xclients.d scripts
e61737
XCLIENTS_D=/etc/X11/xinit/Xclients.d
e61737
if [ "$#" -eq 1 ] && [ -x "$XCLIENTS_D/Xclients.$1.sh" ]; then
e61737
    exec -l $SHELL -c "$SSH_AGENT $XCLIENTS_D/Xclients.$1.sh"
e61737
fi
e61737
e61737
# Failsafe.
e61737
e61737
# these files are left sitting around by TheNextLevel.
e61737
rm -f $HOME/Xrootenv.0
e61737
e61737
# Argh! Nothing good is installed. Fall back to twm
e61737
{
e61737
    # gosh, neither fvwm95 nor fvwm2 is available; 
e61737
    # fall back to failsafe settings
e61737
    [ -x /usr/bin/xsetroot ] && /usr/bin/xsetroot -solid '#222E45'
e61737
e61737
    if [ -x /usr/bin/xclock ] ; then
e61737
	/usr/bin/xclock -geometry 100x100-5+5 &
e61737
    fi
e61737
    if [ -x /usr/bin/xterm ] ; then
e61737
        /usr/bin/xterm -geometry 80x50-50+150 &
e61737
    fi
e61737
    if [ -x /usr/bin/firefox -a -f /usr/share/doc/HTML/index.html ]; then
e61737
	/usr/bin/firefox /usr/share/doc/HTML/index.html &
e61737
    fi
e61737
    if [ -x /usr/bin/twm ] ; then
e61737
	exec /usr/bin/twm
e61737
    fi
e61737
}