updated on Tue Jan 10 04:01:21 UTC 2012
[aur-mirror.git] / lxdm-svn / Xsession
bloba1b15f30a60de4c80fa97d11f98c1b8e29def72f
1 #!/bin/bash
3 # use bash for "exec -l", howto run login shell by /bin/sh ?
4 PROGNAME=/etc/lxdm/Xsession
6 message () {
7 # pretty-print messages of arbitrary length; use xmessage if it
8 # is available and $DISPLAY is set
9 MESSAGE="$PROGNAME: $*"
10 echo "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2
11 if [ -n "$DISPLAY" ] && which xmessage > /dev/null 2>&1; then
12 echo "$MESSAGE" | fold -s -w ${COLUMNS:-80} | xmessage -center -file -
16 message_nonl () {
17 # pretty-print messages of arbitrary length (no trailing newline); use
18 # xmessage if it is available and $DISPLAY is set
19 MESSAGE="$PROGNAME: $*"
20 echo -n "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2;
21 if [ -n "$DISPLAY" ] && which xmessage > /dev/null 2>&1; then
22 echo -n "$MESSAGE" | fold -s -w ${COLUMNS:-80} | xmessage -center -file -
26 errormsg () {
27 # exit script with error
28 message "$*"
29 exit 1
32 # attempt to create an error file; abort if we cannot
33 ERRFILE=$HOME/.xsession-errors
34 if (umask 077 && touch "$ERRFILE") 2> /dev/null && [ -w "$ERRFILE" ] &&
35 [ ! -L "$ERRFILE" ]; then
36 chmod 600 "$ERRFILE"
37 elif ERRFILE=$(tempfile 2> /dev/null); then
38 if ! ln -sf "$ERRFILE" "${TMPDIR:=/tmp}/xsession-$USER"; then
39 message "warning: unable to symlink \"$TMPDIR/xsession-$USER\" to" \
40 "\"$ERRFILE\"; look for session log/errors in" \
41 "\"$TMPDIR/xsession-$USER\"."
43 else
44 errormsg "unable to create X session log/error file; aborting."
46 echo -n >"$ERRFILE" 2>&1
47 exec >>"$ERRFILE" 2>&1
49 # attempt to launch an xsession
50 if [ $# -eq 1 -a -n "$1" ]; then
51 # previously saved or default session
52 LXSESSION=$(which $1 >/dev/null 2>&1)
53 if [ -z "$LXSESSION" ]; then
54 if [ -x /usr/bin/startxfce4 ]; then
55 # try startxfce4
56 LXSESSION=/usr/bin/startxfce4
57 elif [ -x $HOME/.xsession ]; then
58 # user's default
59 LXSESSION=$HOME/.xsession
64 if [ -x /etc/X11/xinit/xinitrc-common ]; then
65 # fedora
66 . /etc/X11/xinit/xinitrc-common
67 if ! [ -z "$XDG_SESSION_COOKIE" ]; then
68 CK_XINIT_SESSION=
69 elif [ -x /usr/bin/ck-launch-session -a -z "$CK_XINIT_SESSION" ]; then
70 CK_XINIT_SESSION="/usr/bin/ck-launch-session"
72 exec -l $SHELL -c "$CK_XINIT_SESSION \"$LXSESSION\""
73 elif [ -x /etc/X11/xinit/Xsession ]; then
74 # fedora
75 exec /etc/X11/xinit/Xsession $LXSESSION
76 elif [ -x /etc/X11/Xsession ]; then
77 # debian, mandriva, ubuntu
78 exec /etc/X11/Xsession $LXSESSION
79 elif [ -x /etc/X11/xinit/xinitrc ]; then
80 #suse
81 export WINDOWMANAGER=$LXSESSION
82 exec -l $SHELL -c /etc/X11/xinitrc
83 else
84 # unknown, user should custom /etc/lxdm/xinitrc self
85 if [ -x /etc/lxdm/xinitrc ]; then
86 . /etc/lxdm/xinitrc
88 if ! [ -z "$XDG_SESSION_COOKIE" ]; then
89 CK_XINIT_SESSION=
90 elif [ -x /usr/bin/ck-launch-session ]; then
91 CK_XINIT_SESSION="/usr/bin/ck-launch-session"
93 exec -l $SHELL -c "$CK_XINIT_SESSION \"$LXSESSION\""