#!/sbin/runscript # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License, v2 # $Header: /var/cvsroot/gentoo-x86/x11-apps/xinit/files/xdm.start,v 1.4 2006/04/21 23:40:14 spyderous Exp $ # This is here to serve as a note to myself, and future developers. # # Any Display manager (gdm,kdm,xdm) has the following problem: if # it is started before any getty, and no vt is specified, it will # usually run on vt2. When the getty on vt2 then starts, and the # DM is already started, the getty will take control of the keyboard, # leaving us with a "dead" keyboard. # # Resolution: add the following line to /etc/inittab # # x:a:once:/etc/X11/startDM.sh # # and have /etc/X11/startDM.sh start the DM in daemon mode if # a lock is present (with the info of what DM should be started), # else just fall through. # # How this basically works, is the "a" runlevel is a additional # runlevel that you can use to fork processes with init, but the # runlevel never gets changed to this runlevel. Along with the "a" # runlevel, the "once" key word means that startDM.sh will only be # run when we specify it to run, thus eliminating respawning # startDM.sh when "xdm" is not added to the default runlevel, as was # done previously. # # This script then just calls "telinit a", and init will run # /etc/X11/startDM.sh after the current runlevel completes (this # script should only be added to the actual runlevel the user is # using). # # Martin Schlemmer # aka Azarah # 04 March 2002 # Start X Font Server before X depend() { need localmount # this should start as early as possible # we can't do 'before *' as that breaks it after bootmisc readahead-list before alsasound net.lo # Start before X use acpid hald xfs } setup_dm() { source /etc/profile.env export PATH="/bin:/sbin:/usr/bin:/usr/sbin:${ROOTPATH}" local MY_XDM="$(echo ${DISPLAYMANAGER} | awk '{ print tolower($1) }')" case "${MY_XDM}" in kdm|kde|kde2|kde3) EXE="$(which kdm)" ;; entrance*) EXE="$(which entranced)" ;; gdm|gnome) EXE=/usr/bin/gdm ;; wdm) EXE=/usr/bin/wdm ;; *) EXE= # Fix #65586, where MY_XDM is empty so EXE=somedir [ -x "/usr/bin/${MY_XDM}" -a -f "/usr/bin/${MY_XDM}" ] \ && EXE="/usr/bin/${MY_XDM}" [ -z "${EXE}" ] && EXE="/usr/bin/xdm" ;; esac test ! -x "${EXE}" && EXE=/usr/bin/xdm SERVICE="${EXE##*/}" } choose_layout() { #some personnal stuff to switch between nv and nvidia drivers and glx local btpopt if [ -e /etc/forceX ] then source /etc/forceX if [ $nvdriver == nv ] then cp /etc/X11/xorg.conf.riva /etc/X11/xorg.conf && [[ `eselect opengl show` = "nvidia" ]] && eselect opengl set xorg-x11 else cp /etc/X11/xorg.conf.nv /etc/X11/xorg.conf && [[ `eselect opengl show` != "nvidia" ]] && eselect opengl set nvidia fi case "$nvlayout" in "TwinTV"|"CloneTV"|"Twin"|"Clone"|"Ext") ;; *) nvlayout="Mono" ;; esac else nvlayout="Mono" if [[ `grep nonvidia /proc/cmdline` != "" ]] then cp /etc/X11/xorg.conf.riva /etc/X11/xorg.conf && [[ `eselect opengl show` = "nvidia" ]] && eselect opengl set xorg-x11 else if [[ `modprobe nvidia && echo "0" ` ]] then cp /etc/X11/xorg.conf.nv /etc/X11/xorg.conf && [[ `eselect opengl show` != "nvidia" ]] && eselect opengl set nvidia for btpopt in $(< /proc/cmdline) do case "${btpopt%=*}" in "nvlayout") case "${btpopt##*=}" in "TwinTV"|"CloneTV"|"Twin"|"Clone"|"Ext") nvlayout="${btpopt##*=}" ;; esac ;; esac done else cp /etc/X11/xorg.conf.riva /etc/X11/xorg.conf && [[ `eselect opengl show` = "nvidia" ]] && eselect opengl set xorg-x11 fi fi fi #Select the desired layout according to bootparams #for kde 3.3 #echo ":0 local@tty1 /usr/X11R6/bin/X -nolisten tcp -layout $nvlayout" > /usr/kde/3.3/share/config/kdm/Xservers #for kde 3.4 #sed -e "/^ServerArgsLocal=/s/-layout [a-Z]*/-layout $nvlayout/" /usr/kde/3.4/share/config/kdm/kdmrc.bak > /usr/kde/3.4/share/config/kdm/kdmrc #for gdm sed -e "/^command=\/usr\/bin\/X/s/-layout [A-z]*/-layout $nvlayout/" /etc/X11/gdm/gdm.conf > /tmp/gdm.conf && mv -f /tmp/gdm.conf /etc/X11/gdm/gdm.conf if [[ `grep noXgl /proc/cmdline` != "" ]] then sed -ie "/^0=/s/0=Xgl/0=Standard/" /etc/X11/gdm/gdm.conf ln -sf /etc/X11/dm/Sessions/xfce-nonXgl.desktop /etc/X11/dm/Sessions/xfce.desktop ln -sf /etc/xdg/xfce4-session/xfce4-session-nonXgl.rc /etc/xdg/xfce4-session/xfce4-session.rc else sed -ie "/^0=/s/0=Standard/0=Xgl/" /etc/X11/gdm/gdm.conf ln -sf /etc/X11/dm/Sessions/xfce-Xgl.desktop /etc/X11/dm/Sessions/xfce.desktop ln -sf /etc/xdg/xfce4-session/xfce4-session-Xgl.rc /etc/xdg/xfce4-session/xfce4-session.rc fi } cmdline_opt() { if [[ "$#" -ne 1 ]]; then return 1 fi for opt in $(/dev/null fi eend 0 fi } stop() { local retval=0 local curvt="$(fgconsole)" local myexe="$(get_options "service")" local myservice="${myexe##*/}" ebegin "Stopping ${myservice}" rm -f ${svcdir}/options/xdm/service if [ "$(ps -A | grep -e "${myservice}")" ] then start-stop-daemon --stop --quiet \ --exec ${myexe} &>/dev/null retval=$? fi #switch back to original vt chvt "${curvt}" &>/dev/null eend ${retval} "Error stopping ${myservice}." return ${retval} } # vim:ts=4