:>> I can post my altered "Xsession" which does exactly this if you are
:>> willing to give it a try.  
:>
:>Sure send it, I will see to integrate it with initscripts and others so we
:>can make it an option in /etc/sysconfig to force it system wide or make it
:>a per-user option

Here it comes... I think It can be used "as is": 

- ssh-agent is started only if the user has ".ssh/identity" AND
"ssh-agent" exists. (User has to start "ssh-add" by himself later.)

-If "identity" does not exist, or "ssh-agent" is not in the path, script
behaves as before. 

Please test this  on various environments. It works for "kde",
"gnome" and "WindowMaker", AFAIK. No idea what to do with "Xfce" though.  

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#!/bin/bash -login
# (c) 1999 Red Hat Software, Inc.
# Modification for Linux-Mandrake by Chmouel Boudjnah <[EMAIL PROTECTED]>
# Modifications for ssh-agent by Denis Havlik <[EMAIL PROTECTED]>
xsetroot -solid \#356390

# redirect errors to a file in user's home directory if we can
for errfile in "$HOME/.xsession-errors" "${TMPDIR-/tmp}/xses-$USER" "/tmp/xses-$USER"
do
    if ( cp /dev/null "$errfile" 2> /dev/null )
    then
        chmod 600 "$errfile"
        exec > "$errfile" 2>&1
        break
    fi
done

# clean up after xbanner
if [ -f /usr/X11R6/bin/freetemp ]; then
    freetemp
fi

# If the "identity" exist, we can assume the user wants to use ssh-agent  
# If ssh-agent exists, he will get it, else nothing happens.
if [ -f $HOME/.ssh/identity ]; then
   SSH_AGENT=`which ssh-agent`
fi

userresources=$HOME/.Xresources 
usermodmap=$HOME/.Xmodmap 
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources 
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap 

# merge in defaults and keymaps 
if [ -f $sysresources ]; then 
    xrdb -merge $sysresources 
fi 
 
if [ -f $sysmodmap ]; then 
    xmodmap $sysmodmap 
fi 
 
if [ -f $userresources ]; then 
    xrdb -merge $userresources 
fi 
 
if [ -f $usermodmap ]; then 
    xmodmap $usermodmap 
fi 

# now, we see if xdm/gdm/kdm has asked for a specific environment
# If the user uses ssh, enviroment get started from ssh-agent, 
# except for the "Xfce" (this one has a funny start sequence) and
# "failsafe". 
case $# in
1)
    case $1 in
        kde)
        exec $SSH_AGENT startkde
        ;;
        gnome)
        exec $SSH_AGENT gnome-session
        ;;
        anotherlevel)
    # we assume that switchdesk is installed.
        exec $SSH_AGENT /usr/share/apps/switchdesk/Xclients.anotherlevel
        ;;
        WindowMaker)
        [ -f $HOME/GNUstep/Defaults/WindowMaker ] || {
                /usr/X11R6/bin/wmaker.inst --batch
        }
        exec $SSH_AGENT /usr/X11R6/bin/wmaker
        ;;      
        AfterStep)
        exec $SSH_AGENT /usr/X11R6/bin/afterstep
        ;;
        Icewm)
        exec $SSH_AGENT /usr/X11R6/bin/icewm
        ;;
        Xfce)
        for i in $(ls $HOME/Desktop/Autostart/); do
            if test -x $HOME/Desktop/Autostart/$i; then
                $HOME/Desktop/Autostart/$i &
            fi
        done
        exec $SSH_AGENT xfwm
        ;;
        failsafe)
        exec xterm -geometry 80x24-0-0
        ;;
    esac
esac

# otherwise, take default action
if [ -x "$HOME/.xsession" ]; then
    exec "$HOME/.xsession"
elif [ -x "$HOME/.Xclients" ]; then
    exec "$HOME/.Xclients"
elif [ -x /etc/X11/xinit/Xclients ]; then
    exec /etc/X11/xinit/Xclients
else
    exec xsm
fi

Reply via email to