~ubuntu-branches/ubuntu/warty/gdm/warty

« back to all changes in this revision

Viewing changes to debian/Xsession

  • Committer: Bazaar Package Importer
  • Author(s): Jeff Waugh
  • Date: 2004-10-13 22:47:01 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041013224701-k1kdko9usv2lndyb
Tags: 2.6.0.3-1ubuntu20
* config/gdm.conf.in:
  - Change GDM background colour to desktop default.
  - Disable gdmlogin branding (don't have a good logo image handy).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
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'
 
9
#
 
10
# (Note that other arguments could also follow, but only the command one is
 
11
# right now relevant and supported)
 
12
#
 
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
 
19
# be set from gdm.
 
20
#
 
21
# Also note that this is not run as a login shell, this is just executed.
 
22
#
 
23
# based on:
 
24
# $XConsortium: Xsession /main/10 1995/12/18 18:21:28 gildea $
 
25
 
 
26
PROGNAME=Xsession
 
27
 
 
28
message () {
 
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 -
 
38
    fi
 
39
  fi
 
40
}
 
41
 
 
42
message_nonl () {
 
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 -
 
52
    fi
 
53
  fi
 
54
}
 
55
 
 
56
errormsg () {
 
57
  # exit script with error
 
58
  message "$*"
 
59
  exit 1
 
60
}
 
61
 
 
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.
 
67
  errormsg "$*" \
 
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>."
 
71
}
 
72
 
 
73
run_parts () {
 
74
  # until run-parts --noexec is implemented
 
75
  if [ -z "$1" ]; then
 
76
    internal_errormsg "run_parts() called without an argument."
 
77
  fi
 
78
  if [ ! -d "$1" ]; then
 
79
    internal_errormsg "run_parts() called, but \"$1\" does not exist or is" \
 
80
                      "not a directory."
 
81
  fi
 
82
  for F in $(ls $1); do
 
83
    if expr "$F" : '[[:alnum:]_-]\+$' > /dev/null 2>&1; then
 
84
      if [ -f "$1/$F" ]; then
 
85
        echo "$1/$F"
 
86
      fi
 
87
    fi
 
88
  done
 
89
}
 
90
# initialize variables for use by all session scripts
 
91
 
 
92
OPTIONFILE=/etc/X11/Xsession.options
 
93
 
 
94
SYSRESOURCES=/etc/X11/Xresources
 
95
USRRESOURCES=$HOME/.Xresources
 
96
 
 
97
SYSSESSIONDIR=/etc/X11/Xsession.d
 
98
USERXSESSION=$HOME/.xsession
 
99
ALTUSERXSESSION=$HOME/.Xsession
 
100
 
 
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..."
 
104
 
 
105
# Translation stuff
 
106
if [ -x "/usr/lib/gdm/gdmtranslate" ] ; then
 
107
  gdmtranslate="/usr/lib/gdm/gdmtranslate"
 
108
else
 
109
  gdmtranslate=
 
110
fi
 
111
 
 
112
# Note that this should only go to zenity dialogs which always expect utf8
 
113
gettextfunc () {
 
114
  if [ "x$gdmtranslate" != "x" ] ; then
 
115
    "$gdmtranslate" --utf8 "$1"
 
116
  else
 
117
    echo "$1"
 
118
  fi
 
119
}
 
120
 
 
121
zenity=`which zenity 2>/dev/null`
 
122
xmessage=`which xmessage 2>/dev/null`
 
123
 
 
124
command="$1"
 
125
 
 
126
if [ -z "$command" ] ; then
 
127
  command=failsafe
 
128
fi
 
129
 
 
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"`
 
133
  else
 
134
    echo "$0: Starting the failsafe xterm session."
 
135
  fi
 
136
  exec xterm -geometry 80x24+0+0
 
137
fi
 
138
 
 
139
# clean up after xbanner
 
140
freetemp=`which freetemp 2>/dev/null`
 
141
if [ -n "$freetemp" ] ; then
 
142
        "$freetemp"
 
143
fi
 
144
 
 
145
usermodmap="$HOME/.Xmodmap"
 
146
userxkbmap="$HOME/.Xkbmap"
 
147
 
 
148
if [ -f "$userxkbmap" ]; then
 
149
    setxkbmap `cat "$userxkbmap"`
 
150
    XKB_IN_USE=yes
 
151
fi
 
152
 
 
153
# xkb and xmodmap don't play nice together
 
154
if [ -z "$XKB_IN_USE" ]; then
 
155
    if [ -f "$usermodmap" ]; then
 
156
       xmodmap "$usermodmap"
 
157
    fi
 
158
fi
 
159
 
 
160
unset XKB_IN_USE
 
161
 
 
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
 
165
  LANG="$GDM_LANG"
 
166
  export LANG
 
167
 
 
168
  if [ -n "$LC_ALL" ]; then
 
169
    if [ "$LC_ALL" != "$LANG" ]; then
 
170
      LC_ALL="$LANG"
 
171
    fi
 
172
  else
 
173
    unset LC_ALL
 
174
  fi
 
175
 
 
176
  if [ -n "$LANGUAGE" ]; then
 
177
    if [ "$LANGUAGE" != "$LANG" ]; then
 
178
      LANGUAGE="$LANG"
 
179
    fi
 
180
  else
 
181
    unset LANGUAGE
 
182
  fi
 
183
 
 
184
  if [ -n "$LINGUAS" ]; then
 
185
    if [ "$LINGUAS" != "$LANG" ]; then
 
186
      LINGUAS="$LANG"
 
187
    fi
 
188
  else
 
189
    unset LINGUAS
 
190
  fi
 
191
fi
 
192
 
 
193
# The default Debian session runs xsession first, so we just do that for
 
194
# "custom"
 
195
if [ "x$command" = "xcustom" ] ; then
 
196
  shift
 
197
  set default $*
 
198
fi
 
199
 
 
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
 
203
# other
 
204
SESSIONFILES=$(run_parts $SYSSESSIONDIR)
 
205
if [ -n "$SESSIONFILES" ]; then
 
206
  for SESSIONFILE in $SESSIONFILES; do
 
207
    . $SESSIONFILE
 
208
  done
 
209
fi
 
210
 
 
211
echo "$0: Executing $command failed, will try to run x-terminal-emulator"
 
212
 
 
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"`
 
215
fi
 
216
 
 
217
exec x-terminal-emulator -geometry 80x24+0+0