diff options
Diffstat (limited to 'prefdm')
-rwxr-xr-x | prefdm | 107 |
1 files changed, 68 insertions, 39 deletions
@@ -1,53 +1,82 @@ #!/bin/sh PATH=/sbin:/usr/sbin:/bin:/usr/bin +HOME=/root +export HOME -# We need to source this so that the login screens get translated -[ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n +# trap SIGTERM to be able to kill autologin +killed () { + kill -15 $! + exit +} + + +# Try autologin first, if wanted... +if [ -f /etc/sysconfig/autologin -a -x /usr/sbin/autologin ]; then + . /etc/sysconfig/autologin + if [ -n "$USER" -a "$AUTOLOGIN" = yes ]; then + # shut down boot splash + [ -x /bin/plymouth ] && /bin/plymouth quit + /usr/sbin/autologin & + echo -n $$ > /var/lock/subsys/dm + wait $! + fi +fi -# Run preferred X display manager -quit_arg= -preferred= +# we have to assume that /etc/sysconfig/desktop has two variables, DESKTOP +# and DISPLAYMANAGER because administors may prefer a specific DM regardless +# of desktops. +# DISPLAYMANAGER is referenced by this script, and DESKTOP is referenced +# as system-wide default by /etc/X11/Xsession script only when X-session +# is opened by "startx" command. +# when DMs open an X-session, they send DESKTOP, which is in this case +# directly selected by users, as a commandline argument of /etc/X11/Xsession. +# actually Xsession script is only able to know by existance of its first +# argument whether it is called by DM or "startx". see the logic +# in /etc/X11/Xsession. +# If DISPLAYMANAGER is not defined, then assume that it is the same as DESKTOP +dm= if [ -f /etc/sysconfig/desktop ]; then - . /etc/sysconfig/desktop - if [ "$DISPLAYMANAGER" = GNOME ]; then - preferred=/usr/sbin/gdm - quit_arg="--retain-splash" - elif [ "$DISPLAYMANAGER" = KDE ]; then - preferred=/usr/bin/kdm - quit_arg="--retain-splash" - elif [ "$DISPLAYMANAGER" = WDM ]; then - preferred=/usr/bin/wdm - elif [ "$DISPLAYMANAGER" = XDM ]; then - preferred=/usr/bin/xdm + . /etc/sysconfig/desktop >/dev/null 2>&1 + [ -z "$DISPLAYMANAGER" ] && DISPLAYMANAGER=$DESKTOP + if [ "$DISPLAYMANAGER" = "GDM" -o "$DISPLAYMANAGER" = "gdm" -o "$DISPLAYMANAGER" = "GNOME" -o "$DISPLAYMANAGER" = "gnome" -o "$DISPLAYMANAGER" = "Gnome" ]; then + dm=GNOME + # only new gdm will shutdown plymouth itself + [ ! -d "/var/run/gdm" ] || no_plymouth_quit="yes" + elif [ "$DISPLAYMANAGER" = "KDE" -o "$DISPLAYMANAGER" = "kde" ]; then + dm=KDE +# no_plymouth_quit="yes" + elif [ "$DISPLAYMANAGER" = "KDM" -o "$DISPLAYMANAGER" = "kdm" ]; then + dm=KDM +# no_plymouth_quit="yes" + elif [ "$DISPLAYMANAGER" = "WDM" -o "$DISPLAYMANAGER" = "wdm" ] ; then + dm=WDM + elif [ "$DISPLAYMANAGER" = "XDM" -o "$DISPLAYMANAGER" = "xdm" ] ; then + dm=XDM + elif [ "$DISPLAYMANAGER" = "SLiM" -o "$DISPLAYMANAGER" = "slim" ] ; then + dm=SLiM elif [ -n "$DISPLAYMANAGER" ]; then - preferred=$DISPLAYMANAGER - else - quit_arg="--retain-splash" - fi -else - quit_arg="--retain-splash" + dm=$DISPLAYMANAGER + fi fi # shut down boot splash -/usr/bin/plymouth quit $quit_arg - -shopt -s execfail +[ -x /bin/plymouth ] && [ "x$no_plymouth_quit" != "xyes" ] && /bin/plymouth quit -[ -n "$preferred" ] && exec $preferred "$@" >/dev/null 2>&1 </dev/null +# xdm-like program are launched from the console, however, the locale-setting +# can be done in a way that console is not localize, while X11 is. +# That is handled by the lang.sh script, depending on the existance of +# $DISPLAY or $DESKTOP variable. Now that $DESKTOP is defined resource lang.sh +[ -z "$DESKTOP" ] && DESKTOP=dummy_DESKTOP_variable +# We need to source this so that the login screens get translated +. /etc/profile.d/10lang.sh +[ "$DESKTOP" = "dummy_DESKTOP_variable" ] && unset DESKTOP -# Fallbacks, in order -exec gdm "$@" >/dev/null 2>&1 </dev/null -exec kdm "$@" >/dev/null 2>&1 </dev/null +preferred=`/etc/X11/lookupdm "$dm"` -for pkg in $(rpm -q --qf "%{NAME}\n" --whatprovides "service(graphical-login)"| LC_ALL=C sort -u) ; do - dm=$(rpm -q --provides $pkg | awk '/^service\(graphical-login\)/ { print $3 ; exit }') - if [ -n "$dm" ]; then - exec $dm "$@" >/dev/null 2>&1 </dev/null - else - exec $pkg "$@" >/dev/null 2>&1 </dev/null - fi -done +if [ -n "$preferred" ]; then + $preferred -nodaemon "$@" >/dev/null 2>&1 & + echo -n $! > /var/run/dm.pid +fi -# catch all exit error -exit 1 +exit 0 |