#!/sbin/runscript # Copyright 1999-2004 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 # $Header: $ PIDFILE=/var/run/syndaemon.pid WHICH_DM="$(echo ${DISPLAYMANAGER} | awk '{ print tolower($1) }')" NUM="0" RETRY="3" depend() { need xdm } waitforx() { while [ $NUM -lt $RETRY ]; do ps -o command -C 'X' | grep X 1>/dev/null 2>&1 if [ $? -eq 0 ]; then break else sleep 1 let NUM=NUM+1 fi done } importmagiccookie() { if [ $WHICH_DM = gdm ]; then ls /var/lib/gdm/\:?.Xauth 1>/dev/null 2>&1 if [ $? -eq 0 ]; then cat /var/lib/gdm/\:?.Xauth | xauth merge - 1>/dev/null 2>&1 WHICH_DISPLAY="`ps -o command -C 'X' | grep X | cut -d " " -f2`" export DISPLAY="$WHICH_DISPLAY" else errorinmagiccookie fi elif [ $WHICH_DM = xdm ]; then ls /etc/X11/xdm/authdir/authfiles/?\:* 1>/dev/null 2>&1 if [ $? -eq 0 ]; then cat /etc/X11/xdm/authdir/authfiles/?\:* | xauth merge - 1>/dev/null 2>&1 WHICH_DISPLAY="`ps -o command -C 'X' | grep X | awk -F"/" '{ print $NF }' | cut -b 2-3`" export DISPLAY="$WHICH_DISPLAY" else errorinmagiccookie fi elif [ $WHICH_DM = kdm ]; then ls /var/run/xauth/?\:* 1>/dev/null 2>&1 if [ $? -eq 0 ]; then cat /var/run/xauth/?\:* | xauth merge - 1>/dev/null 2>&1 WHICH_DISPLAY="`ps -o command -C 'X' | grep X | awk -F"/" '{ print $NF }' | cut -b 2-3`" export DISPLAY="$WHICH_DISPLAY" else errorinmagiccookie fi elif [ $WHICH_DM = entrance ]; then eerror "I dont know what to do with entrance" eend 1 else eerror "No valid Display Manager found in your /etc/rc.conf" fi } errorinmagiccookie() { eerror "Magic Cookie not found or $WHICH_DM is not running" eend 1 } start() { ebegin "Starting syndaemon" waitforx || return 1 importmagiccookie || return 1 start-stop-daemon --start --quiet \ --pidfile ${PIDFILE} --make-pidfile \ --background \ --exec /usr/X11R6/bin/syndaemon -- -i ${SYNDAEMON_TIME} eend $? } stop() { ebegin "Stopping syndaemon" if [ -f ${PIDFILE} ]; then start-stop-daemon --stop --quiet \ --pidfile ${PIDFILE} fi rm -f ${PIDFILE} eend $? }