X Startup 

http://www.mojavelinux.com/wiki/doku.php?id=notebook:xstartup

One of the most misunderstood workflows is the scripts that lead up to the start of the window manager. At least, I have always found myself at a loss of what actually takes place. This page details some of my findings when working with the Fedora and Debian distributions. In then end, I should hope that you know where to stick that environment variable setting so that it evaluates on X login (window manager environment).

Debian Process 

  1. GDM (the login manager) presents the user with a graphical login screen (alternatively, startx can be invoked from a virtual console)
  2. X sessions started by xinit (startx) use the global configuration file /etc/X11/xinit/xinitrc
  3. xinitrc immediately hands off the login to the /etc/X11/Xsession script
  4. Xsession defines two user session scripts, $HOME/.xsession and $HOME/.Xsession
  5. Xsession runs through the /etc/X11/Xsession.d/ directory and executes the scripts in numeric order (allows the control of execution order)

    1. The /etc/X11/Xsession.d/50xorg-common_determine-startup script checks if the user session script exists (and is executable), and if so stores that script in the $STARTUP variable
    2. otherwise, the value of $STARTUP is set to a system default window manager (usually controlled through symlinks)
  6. the very last script, /etc/X11/Xsession.d/99xorg-common_start executes the $STARTUP variable by running exec $STARTUP

Note: Fedora calls the exec command with the login flag (-l), which triggers the shell profile scripts to execute. Debian, on the other hand, uses a raw exec call, so it is necessary to create a $HOME/.xsession script in order to execute the shell login scripts, such as ~/.bash_profile

Red Hat/Fedora Process 

documented on: 2006.07.22