Thursday, March 18, 2010

Customizing X Session

X is the default X server, xinit is the initialization tool to ease the configuration of X session if you are not using display manager (you can specify nicely which client to run, client options, '--' separator for server related part, server to use, server options). Anyway if you run it without any parameters, it will search for client startup script $HOME/.xinitrc (if it doesn't exists it uses default xterm), in similar way it will search for X server startup script $HOME/.xserverrc (if it doesn't exists it uses default X executable). For ultimate source of information see man page.

startx is just a script that builds on top of xinit interface. You can pass a parameters there (client part and server part) reverting to the behaviour of xinit. By default script is trying to find $HOME/.xinitrc and if it doesn't exists the /etc/X11/xinit/xinitrc will be used. In similar way $HOME/.xserverrc will be searched with fallback to /etc/X11/xinit/xserverrc. For other not mentioned important details just consult the /usr/bin/startx script source or the man page.

If you use your own $HOME/.xinitrc you are overriding /etc/X11/xinit/xinitrc. Look there what you are missing. Probably you would like to merge your X resources and some other stuff before you actually run clients.

GDM is a display manager. Usually you will have it specified in your /etc/inittab file or you can run it as service on startup (on arch linux put it to DEAMONS field in /etc/rc.conf). Anyway this display manager while running has somewhere on the screen (sometimes after selecting of user) combobox for session type selection. This combo is populated from the /usr/share/xsesssions directory. Usually when you install some window manager it will create a respective file there. If not, create it manually. The source of information what is happing while launching session is the /etc/gdm/Xsession script. From the documentation of this script it is obvious that as a parameter to the script executable of the session is passed. There are two special commands 'custom' and 'default'. The 'custom' will search for file $HOME/.xsession which needs to be executable and use it as a session client. If the file cannot be found the 'default' command is applied. In 'default' searching is done for executable Xclients on various locations, finally if even this is not successful the ultimate fallback is the xterm client.

To be able to select 'custom' and 'default' in GDM create files in /usr/share/xsession directory.

/usr/share/xsession/custom.desktop
Encoding=UTF-8
Name=Custom
Comment=This starts custom session
Exec=custom
Type=Application
/usr/share/xsession/default.desktop
Encoding=UTF-8
Name=Default
Comment=This starts default session
Exec=default
Type=Application
/usr/share/xsession/xmonad.desktop
Encoding=UTF-8
Name=Xmonad
Comment=This starts xmonad session
Exec=xmonad-session
Type=Application