blob: 33a003ac21a34100e2fe4a6811953caaaad87977 (
plain) (
tree)
|
|
#!/bin/bash
#
# /etc/X11/Xsession
#
# Xsession is executed to start the user's session (as the user)
#
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/sbin:/opt/openslx/bin"
PROGNAME=Xsession
message () {
# pretty-print messages of arbitrary length; use xmessage if it
# is available and $DISPLAY is set
MESSAGE="$PROGNAME: $*"
echo "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2
if [ -n "$DISPLAY" ] && which xmessage > /dev/null 2>&1; then
echo "$MESSAGE" | fold -s -w ${COLUMNS:-80} | xmessage -center -file -
fi
}
errormsg () {
# exit script with error
message "$*"
exit 1
}
# Make sure we source the global profile - needed for ssh-agent, etc.
[ -e "/etc/profile" ] && . "/etc/profile"
# Workaround to start Xsession. The original Xsession script includes error handling functionality and sources other scrips from the Xsession.d/ directory.
SESSIONDIR="/etc/X11/Xsession.d"
tmpfile="$( mktemp "/tmp/xsession-log-$( date +%s )-XXXXXX" )"
if [ -n "$tmpfile" ]; then
exec &> "$tmpfile"
set -x
fi
if [ -d "$SESSIONDIR" ]; then
for file in "$SESSIONDIR"/*; do
[ -f "$file" ] || continue
. "$file"
done
fi
# start selected session
case "$1" in
failsafe)
# Failsafe session was requested.
if [ -e /usr/bin/xterm ]; then
if [ -x /usr/bin/xterm ]; then
exec xterm -geometry +1+1
else
# fatal error
errormsg "unable to launch failsafe X session ---" \
"x-terminal-emulator not executable; aborting."
fi
else
# fatal error
errormsg "unable to launch failsafe X session ---" \
"x-terminal-emulator not found; aborting."
fi
;;
default)
# Specific program was requested.
SESSION="default"
if [ -s "$HOME/.dmrc" ]; then
SESSION=$( < "$HOME/.dmrc" grep -m1 "Session" | cut -d "=" -f2 )
fi
# somehow .dmrc is cleared when logging in the first time after boot
if [ -s "$HOME/.dmrc.real" ]; then
SESSION=$( < "$HOME/.dmrc.real" grep -m1 "Session" | cut -d "=" -f2 )
fi
[ "x$SESSION" == "xdefault" ] && SESSION="gnome"
CMD=$( < "/opt/openslx/xsessions/$SESSION.desktop" grep -m1 "Exec" | cut -d "=" -f2-99 | head -n1 )
exec $CMD
;;
*)
# Specific program was requested.
STARTUP_FULL_PATH=$( which "${1%% *}" || true )
if [ -n "$STARTUP_FULL_PATH" ] && [ -e "$STARTUP_FULL_PATH" ]; then
if [ -x "$STARTUP_FULL_PATH" ]; then
exec $1
else
message "unable to launch \"$1\" X session ---" \
"\"$1\" not executable; falling back to default session."
fi
else
message "unable to launch \"$1\" X session ---" \
"\"$1\" not found; falling back to default session."
fi
;;
esac
|