##########################################################################
# file:        SessionInit
# description: Session initialization code common to all session scripts.
#
# This file is to be sourced at the begining of all session scripts in
# the /etc/X11/gdm/Sessions directory. It must be sourced, not executed
# as a child process, for the environment variables and redirection to
# initialize properly.               
#
##########################################################################

# Set the $WM variable to contain the name of the window manager to exec.
script=$0
if [ -L $script ]; then script=`file $script | awk '{print $NF}'`; fi
WM=`echo $script | tr '[:upper:]' '[:lower:]'`
export WM=`basename $WM`

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

#-------------------------------------------------------------------------
#    Comment out for now. 
#-------------------------------------------------------------------------
# "Automatic Login" initialization. Only takes effect if this is the
# first invocation of this script from gdm (no arguments) and while
# in an "automatic login" configuration.
#if [ $# -eq 0 ]; then

   # There are no arguments to this session script. While this is an 
   # "automatic login" session, loop on this script. This lets us
   # to implement a "kiosk" environment and allow the configuration
   # to change between sessions. Also, changing to a "regular login"
   # configuration will break this loop.

#   if [ -n "`grep "AutomaticLogin=" /etc/X11/gdm/gdm.conf | sed 's/^AutomaticLogin=//'`" ]; then
#      while [ -n "`grep "AutomaticLogin=" /etc/X11/gdm/gdm.conf | sed 's/^AutomaticLogin=//'`" ]; do
#         $0 noloop
#      done
#      exit
#   fi
#fi
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------

