3
# This is SORT OF LIKE an X session, but not quite. You get a command as the
4
# first argument (it could be multiple words, so run it with "eval"). As a
5
# special case, the command can be:
6
# failsafe - Run an xterm only
7
# default - Run the appropriate Xclients startup (see the code below)
8
# custom - Run ~/.xsession and if that's not available run 'default'
10
# (Note that other arguments could also follow, but only the command one is
11
# right now relevant and supported)
13
# The output is ALREADY redirected to .xsession-errors in GDM. This way
14
# .xsession-errors actually gets more output such as if the PreSession script
15
# is failing. This also prevents DoS attacks if some app in the users session
16
# can be prodded to dump lots of stuff on the stdout/stderr. We wish to be
17
# robust don't we? In case you wish to use an existing script for other DM's,
18
# you can just not redirect when GDMSESSION is set. GDMSESSION will always
21
# Also note that this is not run as a login shell, this is just executed.
24
# $XConsortium: Xsession /main/10 1995/12/18 18:21:28 gildea $
29
# pretty-print messages of arbitrary length; use xmessage if it
30
# is available and $DISPLAY is set
31
MESSAGE="$PROGNAME: $*"
32
echo "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2
33
if [ -n "$DISPLAY" ]; then
34
if [ -n "$zenity" ]; then
35
"$zenity" --info --text "`gettextfunc "$MESSAGE"`"
36
elif [ -n "$xmessage" ]; then
37
echo "$MESSAGE" | fold -s -w ${COLUMNS:-80} | $xmessage -center -file -
43
# pretty-print messages of arbitrary length (no trailing newline); use
44
# xmessage if it is available and $DISPLAY is set
45
MESSAGE="$PROGNAME: $*"
46
echo -n "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2;
47
if [ -n "$DISPLAY" ]; then
48
if [ -n "$zenity" ]; then
49
"$zenity" --info --text "`gettextfunc "$MESSAGE"`"
50
elif [ -n "$xmessage" ]; then
51
echo -n "$MESSAGE" | fold -s -w ${COLUMNS:-80} | $xmessage -center -file -
57
# exit script with error
62
internal_errormsg () {
63
# exit script with error; essentially a "THIS SHOULD NEVER HAPPEN" message
64
# One big call to message() for the sake of xmessage; if we had two then
65
# the user would have dismissed the error we want reported before seeing the
66
# request to report it.
68
"Please report the installed version of the \"xfree86-common\"" \
69
"package and the complete text of this error message to" \
70
"<debian-x@lists.debian.org>."
74
# until run-parts --noexec is implemented
76
internal_errormsg "run_parts() called without an argument."
78
if [ ! -d "$1" ]; then
79
internal_errormsg "run_parts() called, but \"$1\" does not exist or is" \
83
if expr "$F" : '[[:alnum:]_-]\+$' > /dev/null 2>&1; then
84
if [ -f "$1/$F" ]; then
90
# initialize variables for use by all session scripts
92
OPTIONFILE=/etc/X11/Xsession.options
94
SYSRESOURCES=/etc/X11/Xresources
95
USRRESOURCES=$HOME/.Xresources
97
SYSSESSIONDIR=/etc/X11/Xsession.d
98
USERXSESSION=$HOME/.xsession
99
USERXSESSIONRC=$HOME/.xsessionrc
100
ALTUSERXSESSION=$HOME/.Xsession
102
# this will go into the .xsession-errors along with all other echo's
103
# good for debugging where things went wrong
104
echo "$0: Beginning session setup..."
106
# First read /etc/profile and .profile
107
test -f /etc/profile && . /etc/profile
108
test -f "$HOME/.profile" && . "$HOME/.profile"
109
# Second read /etc/xprofile and .xprofile for X specific setup
110
test -f /etc/xprofile && . /etc/xprofile
111
test -f "$HOME/.xprofile" && . "$HOME/.xprofile"
114
if [ -x "/usr/lib/gdm/gdmtranslate" ] ; then
115
gdmtranslate="/usr/lib/gdm/gdmtranslate"
120
# Note that this should only go to zenity dialogs which always expect utf8
122
if [ "x$gdmtranslate" != "x" ] ; then
123
"$gdmtranslate" --utf8 "$1"
129
zenity=`which zenity 2>/dev/null`
130
xmessage=`which xmessage 2>/dev/null`
134
if [ -z "$command" ] ; then
138
if [ x"$command" = xfailsafe ] ; then
139
if [ -n "$zenity" ] ; then
140
"$zenity" --info --text "`gettextfunc "This is the failsafe xterm session. Windows now have focus only if you have your cursor above them. To get out of this mode type 'exit' in the window in the upper left corner"`"
142
echo "$0: Starting the failsafe xterm session."
144
exec xterm -geometry 80x24+0+0
147
# clean up after xbanner
148
freetemp=`which freetemp 2>/dev/null`
149
if [ -n "$freetemp" ] ; then
153
usermodmap="$HOME/.Xmodmap"
154
userxkbmap="$HOME/.Xkbmap"
156
if [ -f "$userxkbmap" ]; then
157
setxkbmap `cat "$userxkbmap"`
161
# xkb and xmodmap don't play nice together
162
if [ -z "$XKB_IN_USE" ]; then
163
if [ -f "$usermodmap" ]; then
164
xmodmap "$usermodmap"
170
# if GDM_LANG isn't first in LANGUAGE, then unset it.
171
if [ -n "$GDM_LANG" ]; then
172
if [ -n "$LANGUAGE" ]; then
173
if echo "$LANGUAGE" | grep -q -- "^$GDM_LANG"; then
181
# The default Debian session runs xsession first, so we just do that for
183
if [ "x$command" = "xcustom" ] ; then
188
# use run-parts to source every file in the session directory; we source
189
# instead of executing so that the variables and functions defined above
190
# are available to the scripts, and so that they can pass variables to each
192
SESSIONFILES=$(run_parts $SYSSESSIONDIR)
193
if [ -n "$SESSIONFILES" ]; then
194
for SESSIONFILE in $SESSIONFILES; do
199
echo "$0: Executing $command failed, will try to run x-terminal-emulator"
201
if [ -n "$zenity" ] ; then
202
"$zenity" --info --text "`gettextfunc "I could not start your session and so I have started the failsafe xterm session. Windows now have focus only if you have your cursor above them. To get out of this mode type 'exit' in the window in the upper left corner"`"
205
exec x-terminal-emulator -geometry 80x24+0+0