*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Linux man pages -> Xsession (5)              



NAME    [Toc]    [Back]

       Xsession - initialize X session

SYNOPSIS    [Toc]    [Back]

       Xsession [ session-type ]

DESCRIPTION    [Toc]    [Back]

       /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    "DisplayManager*session"	 resource    in    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

   SESSION TYPES    [Toc]    [Back]
       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:

	      invokes a session consisting solely of  /usr/bin/x-terminal-emu-
	      lator (no window manager is launched).  If the x-terminal-emulator
 program cannot be found, the session exits.  The  "failsafe"
	      argument	is  ignored  if  there	is no "allow-failsafe" line in

	      produces the same behavior as if no session  type  argument  had
	      been given at all.

	      starts program if it can be found in the $PATH.  This is usually
	      a session manager or a very featureful window manager.  If  pro-
	      gram is not found, the Xsession script proceeds with its default
	      behavior.  This argument is ignored if there is no  "allow-userxsession"
  line  in 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.)

       Initially, Xsession performs some housekeeping.	It declares a  set  of
       built-in  functions  (see  "BUILT-IN  SHELL FUNCTIONS" below) and variables,
 then attempts to create a log file for the X session.   Historically
 this is called an "error" file, but it catches all sorts of diagnostic
 output from various X clients run in  the  user's  session,  not
       just  error  messages.  If creation of an error file is impossible, the
       script (and thus the X session) aborts.

       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 ".old" or ".broken" appended to the filename.)

       Five scripts are provided by default:

       1)  Argument processing.  Arguments are processed as described in "SESSION
 TYPES" above.  The startup program, if one is identified  at  this
       point,  is  merely stored for later reference, and not immediately executed.

       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 "xrdb -merge".  Next, if the line "allow-user-resources" is
       present	in  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  "allow-user-xsession"  is
       present in 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 "allow-user-xsession" is
       not specified, or no user X session program  can  be  located,  and  no
       failsafe session is to be run, the following programs are searched for:
       /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 "use-ssh-agent" is  present
       in  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

       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	40cus-
       tom_load-xmodmap, to invoke xmodmap(1):


       if [ -x /usr/bin/X11/xmodmap ]; then
	 if [ -f $SYSMODMAP ]; then
	   xmodmap $SYSMODMAP

       if [ -x /usr/bin/X11/xmodmap ]; then
	 if [ -f $USRMODMAP ]; then
	   xmodmap $USRMODMAP

       Those  writing  scripts for Xsession to execute should avail themselves
       of its built-in shell functions, described below.

   BUILT-IN SHELL FUNCTIONS    [Toc]    [Back]
       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    [Toc]    [Back]

       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.

	      Width of terminal device, in character cells.  Used for  formatting
 diagnostic messages.

INPUT FILES    [Toc]    [Back]

	      is a directory containing Bourne shell scripts to be executed by
	      Xsession.  Files	in  this  directory  are  matched  using  run-
	      parts(1) and are sourced, not executed in a subshell.

	      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).

	      contains configuration options for the /etc/X11/Xsession script.
	      See Xsession.options(5) for more information.

	      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.	 .Xre-
	      sources should be used instead.

	      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    [Toc]    [Back]

	      Where standard output and standard error for Xsession script and
	      all X client processes are directed by default.

	      Where  the  X  session  error file is placed if $HOME/.xsession-
	      errors cannot be opened.	The  filename  is  provided  by  temp-

SEE ALSO    [Toc]    [Back]

       Xsession.options(5), X(1), run-parts(1), ssh-agent(1), startx(1), temp-
       file(1), xdm(1), xmodmap(1), xrdb(1), sh(1)

AUTHOR    [Toc]    [Back]

       /etc/X11/Xsession and its associated files in /etc/X11/Xsession.d  were
       written by Stephen Early, Mark Eichin, and Branden Robinson.

Debian GNU/Linux		  2001-11-08			   Xsession(5)
[ Back ]
 Similar pages
Name OS Title
startx IRIX initialize an X session
glInitNames Tru64 initialize the name stack
pthread_rwlockattr_init IRIX initialize/destroy
nissetup HP-UX initialize a NIS+ domain
install-mh Tru64 initialize the MH environment
usinitsema IRIX initialize a semaphore
glinitnames IRIX initialize the name stack
initgroups OpenBSD initialize supplementary group IDs
krb5_crypto_init FreeBSD initialize encryption context
krb5_crypto_destroy FreeBSD initialize encryption context
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service