6.3 xinitrc

xinit(1) is the program that actually starts X; it is called by startx(1), so you may not have noticed it (and probably don't really need to). Its configuration file, however, determines which programs (including and especially the window manager) are run when X starts up. xinit first checks your home directory for a .xinitrc file. If the file is found, it gets run; otherwise, /var/X11R6/lib/xinit/xinitrc (the systemwide default) is used. Here's a simple xinitrc file:

#!/bin/sh
# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
    xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f $userresources ]; then
    xrdb -merge $userresources
fi

if [ -f $usermodmap ]; then
    xmodmap $usermodmap
fi

# start some nice programs

twm &
xclock -geometry 50x50-1+1 &
xterm -geometry 80x50+494+51 &
xterm -geometry 80x20+494-0 &
exec xterm -geometry 80x66+0+0 -name login

All of those “if” blocks are there to merge in various configuration settings from other files. The interesting part of the file is toward the end, where various programs are run. This X session will begin with the twm(1) window manager, a clock, and three terminals. Note the exec before the last xterm. What that does is replace the currently running shell (the one that's executing this xinitrc script) with that xterm(1) command. When the user quits that xterm, the X session will end.

To customize your X startup, copy the default /var/X11R6/lib/xinit/xinitrc to ~/.xinitrc and edit it, replacing those program lines with whatever you like. The end of mine is simply:

# Start the window manager:
exec startkde

Note that there are several xinitrc.* files in /var/X11R6/lib/xinit that correspond to various window managers and GUIs. You can use any of those, if you like.