Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
Xsession(5)
Edit
PageHistory
Diff
Info
LikePages
Xsession !!!Xsession NAME SYNOPSIS DESCRIPTION ENVIRONMENT INPUT FILES OUTPUT FILES SEE ALSO AUTHOR ---- !!NAME Xsession - initialize X session !!SYNOPSIS Xsession [[ ''session-type'' ] !!DESCRIPTION ''/etc/X11/Xsession'' is a Bourne shell (sh(1)) script which is run every time an X Window System session is begun by startx(1) or a display manager such as xdm(1). (Some display managers only invoke ''Xsession'' when specifically directed to so by the user; see the documentation for your display manager to find out more.) Administrators unfamilar with the Bourne shell will likely find the Xsession.options(5) configuration file easier to deal with than ''Xsession'' itself. ''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. startx(1), xdm(1), xinit(1), and other similar programs handle this. By default on a Debian system, ''Xsession'' is used by both common methods of starting the X Window System, __xdm__ and __startx__. To change this for __xdm,__ edit the __/etc/X11/xdm/xdm-config'' file; for __startx__, replace the contents of the ''/etc/X11/xinit/xinitrc'' file. The ''Xsession'' script is quite flexible, and extensive customization of the X startup procedure is possible without modifying the script itself. See '' __SESSION TYPES__ ''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. By default, three different arguments are supported: failsafe invokes a session consisting solely of ''/usr/bin/x-terminal-emulator'' (no window manager is launched). If the x-terminal-emulator program cannot be found, the session exits. The ''Xsession.options''. default produces the same behavior as if no session type argument had been given at all. ''program'' starts ''program'' if it can be found in the $PATH. This is usually a session manager or a very featureful window manager. If ''program'' is not found, the ''Xsession'' script proceeds with its default behavior. This argument is ignored if there is no ''Xsession.options''. (The reason being, if the administrator does not want users writing their own ''.Xsession'' files, it makes little sense to permit them to specify the names of arbitrary programs to run.) __DEFAULT STARTUP PROCEDURE__ Initially, ''Xsession'' performs some housekeeping. It declares a set of built-in functions (see '' ''Xsession'' next confirms that its script directory, ''Xsession.d'', exists. If it does not, the script aborts. After the script directory is confirmed to be present, ''Xsession'' uses an internal implementation of 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 run-parts(1) 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 __ Five scripts are provided by default: 1) Argument processing. Arguments are processed as described in 2) Merging of X resources. run-parts(1) is again used, this time to identify files in the ''/etc/X11/Xresources'' directory that should be processed with ''Xsession.options'', the user's ''$HOME/.Xresources'' file is merged in the same way. 3) 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 the line Xsession.options'', a user-specified session program or script is used. If a program or failsafe argument was given and is allowed (see above), it is used instead. Otherwise, two historically popular names for user X session scripts are searched for: ''$HOME/.xsession'' and ''$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, sh(1). If __/usr/bin/x-session-manager'', ''/usr/bin/x-window-manager'', and ''/usr/bin/x-terminal-emulator''. The first one found is used. If none are found, ''Xsession'' aborts with an error. 4) Start ssh-agent, if needed. If the line Xsession.options'', and no ssh agent process appears to be running already, ssh-agent(1) is marked to be used to execute the startup program determined previously. ''Note: this functionality may move to the ssh package in the future.'' 5) Start the X session. Finally, the startup program is executed, inside a Bourne shell if necessary, and inside an ssh-agent if necessary. The shell's __exec__ command is used to spare a slot in the process table. __CUSTOMIZING THE STARTUP PROCEDURE__ Of course, any of the existing files can be edited in-place. Because the order in which the various scripts in ''/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: * a two-digit number denoting sequence * the name of the package providing the script * an underscore * a description of the script's basic function, using only characters allowed by run-parts(1). Here is an example of how one might write a script, named ''40custom_load-xmodmap'', to invoke xmodmap(1): SYSMODMAP=/etc/X11/Xmodmap USRMODMAP=$HOME/.Xmodmap if [[ -x /usr/bin/X11/xmodmap ]; then if [[ -f $SYSMODMAP ]; then xmodmap $SYSMODMAP fi fi if [[ -x /usr/bin/X11/xmodmap ]; then if [[ -f $USRMODMAP ]; then xmodmap $USRMODMAP fi fi Those writing scripts for ''Xsession'' to execute should avail themselves of its built-in shell functions, described below. __BUILT-IN SHELL FUNCTIONS__ __message__ is used for communicating with the user. It may be given an arbitrarily long message string. It is formatted to the user's terminal width (breaking lines at whitespace) and sent to standard error. __message_nonl__ is used for communicating with the user when a trailing newline is undesirable. It may be given an arbitrarily long message string. It is formatted to the user's terminal width (breaking lines at whitespace) and sent to standard error. __errormsg__ is used for indicating an error condition and aborting the script. It can be used as __message__ above. After displaying the message to standard error, it will exit ''Xsession'' with status 1. !!ENVIRONMENT The following environment variables affect the execution of ''Xsession'': HOME The user's home directory; various files are searched for here. TMPDIR 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. COLUMNS Width of terminal device, in character cells. Used for formatting diagnostic messages. !!INPUT FILES ''/etc/X11/Xsession.d/'' is a directory containing Bourne shell scripts to be executed by ''Xsession''. Files in this directory are matched using run-parts(1) and are __source__d, not executed in a subshell. ''/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 __xrdb -merge__. Files in this directory are matched using run-parts(1). ''/etc/X11/Xsession.options'' contains configuration options for the ''/etc/X11/Xsession'' script. See Xsession.options(5) for more information. ''$HOME/.Xresources'' contains X resources specific to the invoking user's environment. The settings are loaded with __xrdb -merge__. Note that ''$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. ''.Xresources'' should be used instead. ''$HOME/.Xsession'' is a sequence of commands invoking X clients (or a session manager such as xsm(1)). See the manual page for __xinit__ and/or ''/usr/share/doc/xfree86-common/examples/xsession'' for tips on writing an ''.Xsession'' file. !!OUTPUT FILES ''$HOME/.xsession-errors'' Where standard output and standard error for ''Xsession'' script and all X client processes are directed by default. ''$TMPDIR'' Where the X session error file is placed if ''$HOME/.xsession-errors'' cannot be opened. The filename is provided by tempfile(1). !!SEE ALSO Xsession.options(5), __X__(1), run-parts(1), __ssh-agent__(1), startx(1), tempfile(1), xdm(1), xmodmap(1), xrdb(1), sh(1) !!AUTHOR ''/etc/X11/Xsession'' and its associated files in ''/etc/X11/Xsession.d'' were written by Stephen Early, Mark Eichin, and Branden Robinson. ----
One page links to
Xsession(5)
:
Xsession.options(5)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.