summaryrefslogtreecommitdiff
path: root/debian/local/Xsession.5
blob: 74d69110853baa24077081c407a33d64aef7ac50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
.\" $Id: Xsession.5 470 2005-08-02 01:08:36Z dnusinow $
.\"
.\" Copyright 1998-2004 Branden Robinson <branden@debian.org>.
.\"
.\" This is free software; you may redistribute it and/or modify
.\" it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2,
.\" or (at your option) any later version.
.\"
.\" This is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License with
.\" the Debian operating system, in /usr/share/common-licenses/GPL;  if
.\" not, write to the Free Software Foundation, Inc., 59 Temple Place,
.\" Suite 330, Boston, MA 02111-1307 USA
.TH Xsession 5 "2004\-11\-04" "Debian Project"
.SH NAME
Xsession \- initialize X session
.SH SYNOPSIS
Xsession [
.I session\-type
]
.SH DESCRIPTION
.I /etc/X11/Xsession
is a Bourne shell
.RB ( sh (1))
script which is run when an X Window System
session is begun by
.BR startx (1)
or a display manager such as
.BR xdm (1).
(Some display managers only invoke
.I Xsession
when specifically directed to so by the user; see the documentation for
your display manager to find out more.)
Administrators unfamiliar with the Bourne shell will likely find the
.BR Xsession.options (5)
configuration file easier to deal with than
.I Xsession
itself.
.PP
.I Xsession
is not intended to be invoked directly by the user; to be effective it
needs to run in a special environment associated with X server
initialization.
.BR startx ,
.BR xdm ,
.BR xinit (1),
and other similar programs handle this.
.PP
By default on a Debian system,
.I Xsession
is used by both common methods of starting the X Window System,
.B xdm
(or another X display manager) and
.BR startx .
To change this for
.BR xdm,
edit the \(oqDisplayManager*session\(cq resource in the
.I /etc/X11/xdm/xdm\-config
file \(em for other display managers, consult their documentation.
To stop
.B startx
from using
.I Xsession
by default, replace the contents of the
.I /etc/X11/xinit/xinitrc
file.
.PP
The
.I Xsession
script is quite flexible, and extensive customization of the X startup
procedure is possible without modifying the script itself.
See \(lqCUSTOMIZING THE STARTUP PROCEDURE\(rq below.
.SS "SESSION TYPES"
.I Xsession
may optionally be passed a single argument indicating the type of X
session to be started.
It is up to the display manager to set the argument. To pass
.I Xsession
an argument from
.B startx
or
.BR xinit ,
.I /etc/X11/Xsession
(or
.IR /etc/X11/xinit/xinitrc )
must be called explicitly with a path, as in
.B startx /etc/X11/Xsession
.BR failsafe .
By default, three different arguments are supported:
.TP
.B failsafe
invokes a session consisting solely of an
.BR x\-terminal\-emulator (1)
(no window manager is launched).
If the
.B x\-terminal\-emulator program cannot
be found, the session exits.
The \(oqfailsafe\(cq argument is ignored if there is no
\(oqallow\-failsafe\(cq line in
.IR Xsession.options .
.TP
.B default
produces the same behavior as if no session type argument had been given at
all.
.TP
.I program
starts
.I program
if it can be found in the $PATH.
This is usually a session manager or a very featureful window manager.
If
.I program
is not found, the
.I Xsession
script proceeds with its default behavior.
This argument is ignored if there is no \(oqallow\-user\-xsession\(cq line
in
.IR Xsession.options .
(If the administrator does not want users writing their own
.I .xsession
files, it makes little sense to permit them to specify the names of
arbitrary programs to run.)
Note that the restriction may be easy to bypass, e.g. by using a
.I .gnomerc
file instead.
.SS "DEFAULT STARTUP PROCEDURE"
Initially,
.I Xsession
performs some housekeeping.
It declares a set of built\-in functions (see
\(lqBUILT\-IN SHELL FUNCTIONS\(rq below) and variables, then attempts to
create a log file for the X session, or append to an existing one.
Historically this is called an \(oqerror\(cq file, but it catches all sorts
of diagnostic output from various X clients run in the user's session, not
just error messages.
If it is impossible to write to an error file, the script (and thus the X
session) aborts.
For convenience, once the error file is successfully opened,
.I Xsession
reports the fact that the session has started, the invoking username, and
the date to the error file.
This makes it easier to discern which X session produced a particular line
of output in the file.
.PP
.I Xsession
next confirms that its script directory,
.IR Xsession.d ,
exists.
If it does not, the script aborts.
After the script directory is confirmed to be present,
.I Xsession
uses
.BR run\-parts (1)
to identify files in that directory that should be sourced (executed) in the
shell's environment.
Only files named in a certain way are sourced; see the
.B run\-parts
manual page for a description of valid characters in the filename.
(This restriction enables the administrator to move experimental or
problematic files out of the way of the script but keep them in an obvious
place, for instance by renaming them with \(oq.old\(cq or \(oq.broken\(cq
appended to the filename.)
.SS "SUPPLIED SCRIPTS"
Five shell script portions are supplied by default to handle the details of
the session startup procedure.
.TP
.I /etc/X11/Xsession.d/20x11\-common_process\-args
Arguments are processed as described in \(lqSESSION TYPES\(rq above.
The startup program, if one is identified at this point, is merely stored
for later reference, and not immediately executed.
.TP
.I /etc/X11/Xsession.d/30x11\-common_xresources
X resources are merged.
.B run\-parts
is again used, this time to identify files in the
.I /etc/X11/Xresources
directory that should be processed with \(oqxrdb \-merge\(cq.
Next, if the line \(oqallow\-user\-resources\(cq is present in
.IR Xsession.options ,
the user's
.I $HOME/.Xresources
file is merged in the same way.
.TP
.I /etc/X11/Xsession.d/40x11\-common_xsessionrc
Source global environment variables.
This script will source anything in 
.IR $HOME/.xsessionrc
if the file is present. This allows the user to set global environment
variables for their X session, such as locale information.
.TP
.I /etc/X11/Xsession.d/50x11\-common_determine\-startup
Determine startup program.
The X client to launch as the controlling process (the one that, upon
exiting, causes the X server to exit as well) is determined next.
If a program or failsafe argument was given and is allowed (see above), it
is used as the controlling process.
Otherwise, if the line \(oqallow\-user\-xsession\(cq is present in
.IR Xsession.options ,
a user\-specified session program or script is used.
In the latter case, two historically popular names for user X session
scripts are searched for:
.IR $HOME/.xsession
and
.IR $HOME/.Xsession
(note the difference in case).
The first one found is used.
If the script is not executable, it is marked to be executed with the
Bourne shell interpreter,
.BR sh .
Finally, if none of the above succeeds, the following programs are searched
for:
.IR /usr/bin/x\-session\-manager ,
.IR /usr/bin/x\-window\-manager ,
and
.IR /usr/bin/x\-terminal\-emulator .
The first one found is used.
If none are found,
.I Xsession
aborts with an error.
.TP
.I /etc/X11/Xsession.d/90x11\-common_ssh\-agent
Start
.BR ssh\-agent (1),
if needed.
If the line \(oquse\-ssh\-agent\(cq is present in
.IR Xsession.options ,
and no SSH agent process appears to be running already,
.B ssh\-agent
is marked to be used to execute the startup program determined previously.
.B Note:
this functionality may move to the ssh package in the future.
.TP
.I /etc/X11/Xsession.d/99x11\-common_start
Start the X session.
The startup program is executed, inside a Bourne shell if it is not
executable, and inside an ssh\-agent if necessary.
The shell's
.B exec
command is used to spare a slot in the process table.
.SS "CUSTOMIZING THE STARTUP PROCEDURE"
Of course, any of the existing files can be edited in place.
.PP
Because the order in which the various scripts in
.I /etc/X11/Xsession.d
are executed is important, files to be added to this directory should
have a well\-formed name.
The following format is recommended:
.PP
* a two\-digit number denoting sequence;
.PP
* the name of the package providing the script (or \(oqcustom\(cq for
locally\-created scripts);
.PP
* an underscore;
.PP
* a description of the script's basic function, using only characters allowed
by
.BR run\-parts .
.PP
Here is an example of how one might write a script, named
.IR 40custom_load\-xmodmap ,
to invoke
.BR xmodmap (1):
.PP
.nf
SYSMODMAP="/etc/X11/Xmodmap"
USRMODMAP="$HOME/.Xmodmap"
.PP
if [ \-x /usr/bin/X11/xmodmap ]; then
    if [ \-f "$SYSMODMAP" ]; then
        xmodmap "$SYSMODMAP"
    fi
fi
.PP
if [ \-x /usr/bin/X11/xmodmap ]; then
    if [ \-f "$USRMODMAP" ]; then
        xmodmap "$USRMODMAP"
    fi
fi
.fi
.PP
Those writing scripts for
.I Xsession
to execute should avail themselves of its built\-in shell functions,
described below.
.SS "BUILT\-IN SHELL FUNCTIONS"
.B message
is used for communicating with the user.
It is a wrapper for the
.BR echo (1)
command and relies upon
.B echo
for its argument processing.
This function may be given an arbitrarily long message string, which is
formatted to the user's terminal width (breaking lines at whitespace) and
sent to standard error.
If the
.I DISPLAY
environment variable is set and the
.BR xmessage (1)
program is available,
.B xmessage
is also used to display the message.
.PP
.B message_nonl
is used for communicating with the user when a trailing newline is
undesirable; it omits a trailing newline from the message text.
It otherwise works as
.BR message .
.PP
.B errormsg
is used for indicating an error condition and aborting the script.
It works as
.BR message ,
above, except that after displaying the message, it will exit
.I Xsession
with status 1.
.SH ENVIRONMENT
The following environment variables affect the execution of
.IR Xsession :
.TP
.B HOME
specifies the user's home directory; various files are searched for here.
.TP
.B TMPDIR
names a default directory for temporary files; if the standard X session
error file cannot be opened, this variable is used to locate a place for
one.
.TP
.B COLUMNS
indicates the width of terminal device in character cells.
This value is used for formatting diagnostic messages.
.SH "INPUT FILES"
.TP
.I /etc/X11/Xsession.d/
is a directory containing Bourne shell scripts to be executed by
.IR Xsession .
Files in this directory are matched using
.B run\-parts
and are
.BR source d,
not executed in a subshell.
.TP
.I /etc/X11/Xresources/
is a directory containing files corresponding to Debian package names, each of
which contains system\-wide X resource settings for X clients from the
corresponding package.
The settings are loaded with
.BR "xrdb \-merge" .
Files in this directory are matched using
.BR run\-parts .
.TP
.I /etc/X11/Xsession.options
contains configuration options for the
.I /etc/X11/Xsession
script.
See
.BR Xsession.options (5)
for more information.
.TP
.I $HOME/.Xresources
contains X resources specific to the invoking user's environment.
The settings are loaded with
.BR "xrdb \-merge" .
Note that
.I $HOME/.Xdefaults
is a relic from X Version 10 (and X11R1) days, before app\-defaults files
were implemented.
It has been deprecated for over ten years at the time of this writing.
.I .Xresources
should be used instead.
.TP
.I $HOME/.xsession
is a sequence of commands invoking X clients (or a session manager such as
.BR xsm (1)).
See the manual page for
.B xinit
for tips on writing an
.I .xsession
file.
.SH "OUTPUT FILES"
.TP
.I $HOME/.xsession\-errors
is where standard output and standard error for
.I Xsession
script and all X client processes are directed by default.
.TP
.I $TMPDIR/filename
is where the X session error file is placed if
.I $HOME/.xsession\-errors
cannot be opened.
For security reasons, the exact filename is randomly generated by
.BR tempfile (1).
.SH AUTHORS
Stephen Early, Mark Eichin, and Branden Robinson developed Debian's X
session handling scripts.
Branden Robinson wrote this manual page.
.SH "SEE ALSO"
.BR Xsession.options (5),
.BR X (7),
.BR run\-parts (1),
.BR ssh\-agent (1),
.BR startx (1),
.BR tempfile (1),
.BR xdm (1),
.BR xmessage (1),
.BR xmodmap (1),
.BR xrdb (1),
.BR sh (1)
.\" vim:set et tw=80: