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
ALTUSERXSESSION=$HOME/.Xsession
101
# this will go into the .xsession-errors along with all other echo's
102
# good for debugging where things went wrong
103
echo "$0: Beginning session setup..."
106
if [ -x "/usr/lib/gdm/gdmtranslate" ] ; then
107
gdmtranslate="/usr/lib/gdm/gdmtranslate"
112
# Note that this should only go to zenity dialogs which always expect utf8
114
if [ "x$gdmtranslate" != "x" ] ; then
115
"$gdmtranslate" --utf8 "$1"
121
zenity=`which zenity 2>/dev/null`
122
xmessage=`which xmessage 2>/dev/null`
126
if [ -z "$command" ] ; then
130
if [ x"$command" = xfailsafe ] ; then
131
if [ -n "$zenity" ] ; then
132
"$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"`
134
echo "$0: Starting the failsafe xterm session."
136
exec xterm -geometry 80x24+0+0
139
# clean up after xbanner
140
freetemp=`which freetemp 2>/dev/null`
141
if [ -n "$freetemp" ] ; then
145
usermodmap="$HOME/.Xmodmap"
146
userxkbmap="$HOME/.Xkbmap"
148
if [ -f "$userxkbmap" ]; then
149
setxkbmap `cat "$userxkbmap"`
153
# xkb and xmodmap don't play nice together
154
if [ -z "$XKB_IN_USE" ]; then
155
if [ -f "$usermodmap" ]; then
156
xmodmap "$usermodmap"
162
# Normalize languages, some places/distros screw us up in /etc/profile,
163
# so in case the user did select a language
164
if [ -n "$GDM_LANG" ]; then
168
if [ -n "$LC_ALL" ]; then
169
if [ "$LC_ALL" != "$LANG" ]; then
176
if [ -n "$LANGUAGE" ]; then
177
if [ "$LANGUAGE" != "$LANG" ]; then
184
if [ -n "$LINGUAS" ]; then
185
if [ "$LINGUAS" != "$LANG" ]; then
193
# The default Debian session runs xsession first, so we just do that for
195
if [ "x$command" = "xcustom" ] ; then
200
# use run-parts to source every file in the session directory; we source
201
# instead of executing so that the variables and functions defined above
202
# are available to the scripts, and so that they can pass variables to each
204
SESSIONFILES=$(run_parts $SYSSESSIONDIR)
205
if [ -n "$SESSIONFILES" ]; then
206
for SESSIONFILE in $SESSIONFILES; do
211
echo "$0: Executing $command failed, will try to run x-terminal-emulator"
213
if [ -n "$zenity" ] ; then
214
"$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"`
217
exec x-terminal-emulator -geometry 80x24+0+0