Red Hat Linux is configured to run a script called
.Xclients in your home directory each time you start X
Windows using the startx command. If you login to X using
xdm (the X Display Manager), the startup script is called
.xsession in your home directory. You can make sure you run the same
programs in each script by making .xsession a
symbolic link to .Xclients (done by default in the root
account) using the following commands (don't type the lines
beginning with #):
# change to your home directory.
cd ~
# if `.xsession' already exists, rename it in case
# there's something important in it.
mv .xsession .xsession.orig
# link `.xsession' to `.Xclients'.
ln -sf .Xclients .xsession
If you already had a file named .xsession in your home
directory, the second command above renames it. Once you're
certain there is nothing important in it, you can delete it with:
rm .xsession.orig
.Xclients .Xclients is a shell script; it is run when you
start X, and when the script finishes running, X Windows ends as
well. Normally, commands in a shell script are run ``in the
foreground''---that is, each command runs when the previous
command finishes running. Unfortunately, this won't work for an X
Windows startup script, since the first X client you start would
have to exit before the second one could start, and what you
really want to be able to do is to start them all one right after
the other, ``in the background''. You can run commands in the
background by putting an & (ampersand) character at the end of
the command, e.g.:
xclock &
This is how you should run most of the X clients in your
.Xclients script. However, you must be careful to run the
LAST command in .Xclients in the FOREGROUND (i.e., without
the &), otherwise X will start, run your startup script, and
then exit immediately. Under Linux, the convention is to make the
last command start your window manager, so that when you exit your
window manager, you exit X Windows.
.Xclients Script You can make a .Xclients script using your favorite text
editor (e.g., vi, emacs, joe, jed, ed, etc.). Since it's a
script, make sure the first line contains the name of the shell
you want to use to run it, e.g., for sh (the Bourne shell):
#!/bin/sh
or for csh (the C shell):
#!/bin/csh
(if you don't know which shell to use, you may wish to use the example script below as a starting point).
The commands you typically put in your startup script are X clients that you want to run every time you start X Windows, such as a clock, a mailbox checker, a terminal window, or a button bar. The last command should start your window manager.
Here is an example of a simple .Xclients script:
#!/bin/sh
#
# .Xclients: startup script for X Windows
#
# start a clock in the upper lefthand corner.
xclock -geometry +0+0 &
#
# start a program to check for new mail.
xbiff &
#
# start a terminal window for typing commands,
# with a login shell.
xterm -ls &
#
# start a window manager in the foreground;
# when we exit this, we exit X Windows.
# the `exec' command isn't necessary, but it
# saves a little bit of memory.
exec fvwm
#
# -------- End of .Xclients --------
When you're done creating the script, save it to .Xclients in
your home directory, and then make sure you can run it as a script
using the following command:
chmod ug+x .Xclients
Next Chapter, Previous Chapter
Table of contents of this chapter, General table of contents
Top of the document, Beginning of this Chapter