-->

Previous | Table of Contents | Next

Page 186

Listing 10.6. continued


    18 if [ -f $usermodmap ]; then

    19     xmodmap $usermodmap

    20 fi

    21 # Set the background to a dull gray

    22 if [ -f /usr/bin/X11/xsetroot ]; then

    23 xsetroot -solid gray32

    24 fi



    25 if [ -f /usr/bin/X11/xclock ]; then

    26        xclock -geometry 80x80 &

    27 fi



    28 olvwm &

    29 # fvwm &



    30 xterm  -e /bin/bash

The line numbers in this listing have been added for your benefit. Let's look at these lines in greater detail.

Lines 4_7 set the resource environment variables for the X Window installation for your system. Change these to the path of your system's X Window System distribution.

Lines 9 through 20 check for the existence of these resources and then run the appropriate program, xmodmap or xrdb, with these resources as parameters. For now you can use this the way it stands.

Lines 22_24 check for the xsetroot program, and if present, execute it to set the background to a solid color, gray32.

The olvwm & command in line 28 starts the OPEN LOOK window manager for you. If you want to use fvwm instead of olvwm, uncomment line 29 and comment line 28 instead. The window manager must be run in the background if you have more commands following this one.

Line 30 starts a terminal to work with. Because this is the last line in the .xinitrc file, exiting this terminal causes your X session to stop. If you want to start more xterms, you can start them from within this xterm.

A simpler .xinitrc file to start with would be the following:


xterm -name Console &

olvwm

You can then enhance this .xinitrc file with what you want.

The Personal X Resource File

Sometimes you won't be content with default settings for applications that don't have a configuration file of their own. You can change some of these defaults by setting X resources in the .Xresources file in your home directory.

Page 187

NOTE
You should know what effects setting the resources will have on the programs you use. Read the man pages for the program and for xrdb before editing the .Xresources file.

A resource file looks like an application default file. The difference is that in the resource file, resources for several applications are set. You should use the full names (Progname.Resourcename) instead of abbreviating the program name with an asterisk. Examples of application default files can be found in the /usr/X11R6/lib/X11/app-defaults directory. The resources available for a single application are usually shown in the man pages for that application.

If you are running a color server, you might want to put the following lines into your .Xresources file if some programs start in black and white:


#ifdef COLOR

*customization: -color

#endif

If this change is made, the program foo will read both the Foo and the Foo-color application default file from /usr/X11R6/lib/X11/app-defaults. The usual behavior is for Foo only to be read.

NOTE
If you are running a color server, the preceding code definitely should be added to the system .Xresources file. You might mention that to the person or entity who maintains the program you are running.

Note that the black-and-white color scheme of a program may be caused by the program rather than its resources.

The -xrm can be used with most X programs to override the parameters set in your .Xresources file. The usage is


-xrm "resource"

Alternatively, you can use the xrdb <filename> command to enforce any changes you have made in <filename> that apply to your current session.

Using xdm

If you want to run X on your system all the time, you could run xdm from the system startup. xdm is preconfigured on most systems, so you should not have to edit any of the xdm configuration files. Usually a runlevel is attached to an X-only system (look at /etc/inittab). All you have to do to get it working is change the default runlevel. On systems that use an init

Page 188

without runlevels (run man init to see whether your system uses an init), you should look into the /etc/rc and /etc/rc.d/rc.local files; you usually only have to remove comment signs at the beginning of a line that calls xdm. If no such line is present, you probably have a system that has no preconfigured xdm. In any event, xdm by default runs your .xinitrc file for you.

Configuration of the Window Manager

Window managers are a user- and site-specific issue. Several window managers are available for Linux. The configuration of one window manager is quite different from that of another. The window manager used in the configuration is usually explained in your .xinitrc file, so look there. The most commonly used window managers for Linux are

I discuss mwm in greater detail in Chapter 26, "Motif Programming."

Compiling Programs That Use X

Before compiling any programs for X, please read the GCC-HOWTO file. This file can be found in the pub/Linux/docs/HOWTO directories of sunsite or under /usr/doc. Many questions on compiling programs with Linux are answered here.

If you have the source code for a program that uses X11, it is usually shipped with an Imakefile instead of a Makefile.

Imakefiles are files that create Makefiles for your system. Discussing Imakefiles is beyond the scope of this book; however, you will have to work with Imakefiles if you work at all with X sources. Just remember the shell script xmkmf, and you should be okay.

TIP
xmkmf is an abbreviation for X Make Makefile.

Previous | Table of Contents | Next