startx on Red Hat 5.x (fwd)

Bruce Richardson (brichardson@lineone.net)
Thu, 25 Mar 1999 00:58:00 +0000 (GMT)


I wrote this at the request of some newbies on Another Window-manager List
and then posted it on the Red Hat list.  I wasn't going to post it here
because I thought there were far fewer newbies on it than on some others.
That seems to have changed, so here we are:

---------- Forwarded message ----------
Subject: startx on Red Hat 5.x

by Bruce Richardson

I had been tripped up one time too many by Red Hat's totally undocumented
set of X wrapper-scripts, so I went hunting.


The Core: xinit
---------------

startx is just a shell script that acts as a wrapper for xinit, the
program that actually starts X.  A quick summary of xinit is in order:

xinit [ [ client ]  options ] [ -- [ server ] [ display ] options]

The client is the window manager you want to run (see note 1). If you
don't
specify a client, xinit looks for ~/.xinitrc and runs that.  If there is
no ~/.xinitrc then xinit runs xterm.

The server is the X server you want.  If you don't specify a server then
it looks for ~/.xserverrc and runs that.  If there is no ~/.xserverrc then 
X (which should be a soft link to your default X server) is run (on
display :0 unless you specify a display).  

For the benefit of newbies, .xserverrc is unnecessary unless you want to
have more than one X session running at once.


The wrapping: xinitrc, Xclients, xserverrc and .wm_style
--------------------------------------------------------

startx takes the same arguments as xinit (if you give any) and passes them
on to xinit.  So what is added?

Split client scripts: Red Hat split .xinitrc into .xinitrc and .Xclients.
.xinitrc does pre-window-manager setup and .Xclients launches the
window-manager, based on the choice you name in ~/.wm_style.

Extra default layer: Red Hat add the /etc/X11/xinit directory.  If you
don't specify a ~/.xinitrc, .Xclients or .xserverrc then startx looks for
the default (unhidden) version in this directory and passes it to xinit.
On first install this directory has an xinitrc and Xclients but no
xserverrc. 

The sequence of events:  startx looks for ~/.xinitrc to pass to xinit.  If
there is none it looks for /etc/X11/xinit/xinitrc.  xinitrc sets
environment variables and runs xrdb, xmodmap etc., then looks for
~/.Xclients to run.  If there is none it runs /etc/X11/xinit/Xclients.  If
there is none (i.e. you deleted it) it runs fvwm.  If _that_ is not
present then it runs twm (see note 2).

Xclients looks for .wm_style and launches the window manager named there.
If there is no .wm_style it runs fvwm95, failing that fvwm, failing that
twm.

(Details about .wm_style: the RH 5.1 Xclients only actually knows about
AfterStep (Red Hat class fvwm95, fvwm and twm as backup options, not
styles).  You are obviously expected to extend the .wm_style case
statement yourself as you add window-managers.  The RH 5.2 Xclients also
knows about WindowMaker, IceWM and MWM.  It uses simple wrapper-script
called RunWM to launch the window-manager of your .wm_style choice)

On the server side, startx looks for ~/.xserverrc to pass to xinit.  If
there is none it looks for /etc/X11/xinit/xserverrc


How to configure this to your own needs
----------------------------------------

Almost all window-managers create ~/.xinitrc when you install them for a
user.  Unfortunately, this is the worst choice for Red Hat, since
/etc/X11/xinitrc sets up useful environment variables, the keyboard,
Xdefaults etc (things that the window-manager .xinitrc files usually
expect you to add in for yourself - see note 3).

My advice is to have no .xinitrc (see note 4) and let
/etc/X11/xinit/xinitrc do it's useful stuff.  What you _do_ want is your
own ~/.Xclients (see note 5 - no, really, look at note 5).  Here you can
add any extra pre-setup you want (see notes 4 & 6) and then launch your
window-manager of choice.  Newbies should run the user-installation
program for their window-manager and then rename the resulting ~/.xinitrc
to .Xclients.

Remember, if you have your own ~/.Xclients then .wm_style will be ignored
(unless you write it back in).

An alternative option (requiring more initial setup but then easier on the
user) is to extend /etc/X11/xinit/Xclients to cover the range of
window-managers you have installed.  This then allows users to simply
modify .wm_style to change window-managers.

And xserverrc?  Well, unless you frequently use multiple concurrent
displays, there's no need for a local or cenral copy.  People who _do_ run
multiple displays can use .serverrc to tie specific users to specific
displays or (if they're really clever) create a /etc/X11/xinit/xserverrc
script that finds and uses the next unused display.


NOTES
-----

Note 1:  Actually, the client you pass to xinit doesn't have to be a
window-manager: it could be any X program.  The only other program I can
think to use would be an xterm (from which you can launch X programs or
even a window-manager).

Note 2:  twm comes packaged with XFree86, so it should always be there.

Note 3:  Window managers don't do much pre-setup in their .xinitrc files
for the good reason that they don't know what resources you have.  This, I
think, is _the reason_ why Red Hat split off the window-manager-launch
into .Xclients: so you can have a generic setup (xinitrc) and a customised
window manager.  They _really_ ought to make this clear.

Note 4:  If you have to do some extra set-up for X that isn't
window-manager-specifig then either add it to /etc/X11/xinit/xinitrc or
copy that file to ~/.xinitrc and make the changes there (you could just
have ~/.xinitrc do the extra things you want and then call
/etc/X11/xinit/xinitrc).  Alternatively, you could copy
/etc/X11/xinit/xinitrc to /etc/skel/.xinitrc.

Note 5:  One _excellent_ reason for launching your window-manager from
either .Xclients or /etc/X11/xinit/Xclients is that these are also used by
xdm.  So, if you decide to switch to using xdm you keep your favourite
window-manager.  If you use xinitrc with startx and then switch to xdm
then OOPS! here comes fvwm95!

Note 6:  Newbies, be sure that any programs you run before launching your
window-manager are either short-lived or run in the background.  Otherwise
you'll never get as far as the window-manager. 



--
   WWW:   http://www.afterstep.org/
   FTP:   ftp://ftp.afterstep.org/
   MAIL:  http://www.caldera.com/linuxcenter/forums/afterstep.html