#! /bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../kdebase/Xsession.pre
# Copyright (C) 2006 The T2 SDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---

# Xsession - run as user

# 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

DM_PATH=$PATH
test -f /etc/profile && . /etc/profile
test -f $HOME/.profile && . $HOME/.profile
IFS_SAVE=$IFS
IFS=:
for i in $PATH; do
    case :$DM_PATH: in
      *:$i:*) ;;
      ::) DM_PATH=$i;;
      *) DM_PATH=$DM_PATH:$i;;
    esac
done
IFS=$IFS_SAVE
PATH=$DM_PATH
export PATH

test -f /etc/xprofile && . /etc/xprofile
test -f $HOME/.xprofile && . $HOME/.xprofile

sess=$1
shift

case $sess in
    failsafe)
        exec xterm -geometry 80x24-0-0 $*
        ;;