Unix Power ToolsUnix Power ToolsSearch this book

6.5. Setting X Resources: Overview

Learning to write resource specifications is a fairly manageable task, once you understand the basic rules of syntax and precedence. In contrast, the multiple ways you can set resources -- for a single system, multiple systems, a single user, or for all users -- can be confusing. For our purposes, we are primarily concerned with specifying resources for a single user running applications both on the local system and on remote systems in a network.

As we've said, resources are generally specified in files. A resource file can have any name you like. Resources are generally "loaded" into the X server by the xrdb (Section 56.8) client, which is normally run from your startup file or run automatically by xdm when you log in. Prior to Release 2 of X, there was only one resource file called .Xdefaults, placed in the user's home directory. If no resource file is loaded into the server by xrdb, the .Xdefaults file will still be read.

Remember that X allows clients to run on different machines across a network, not just on the machine that supports the X server. One problem with the older .Xdefaults mechanism was that users who were running clients on multiple machines had to maintain multiple .Xdefaults files, one on each machine. By contrast, xrdb stores the application resources directly in the server, thus making them available to all clients, regardless of the machine on which the clients are running. As we'll see, xrdb also allows you to change resources without editing files.

Of course, you may want certain resources to be set on all machines and others to be set only on particular machines. For a complex setup, check the detailed information in O'Reilly & Associates' X Window System Guide, Volume 3M, Chapter 11.

In addition to loading resource files, you can specify defaults for a particular instance of an application from the command line using two options: -xrm and -name.

A sample resources file follows. This file sets the border width for all clients to a default value of two pixels, and it sets other specific variables for xclock and xterm. The meaning of each variable is obvious from its name. (For example, xterm*scrollBar: True means that xterm windows should be created with a scrollbar.)

Note that comments are preceded by an exclamation point (!).

For a detailed description of each variable, see the X client manpages.

*borderWidth:           2
!
! xclock resources
!
xclock*borderWidth:     5
xclock*geometry:        64x64
!
! xterm resources
!
xterm*curses:           on
xterm*cursorColor:      skyblue
xterm*pointerShape:     pirate
xterm*jumpScroll:       on
xterm*saveLines:        300
xterm*scrollBar:        True
xterm*scrollKey:        on
xterm*background:       black
xterm*borderColor:      blue
xterm*borderWidth:      3
xterm*foreground:       white
xterm*font:             8x13

Section 6.6 takes a look at the use of the -xrm command-line option in standard X clients; Section 6.7 covers -name. Section 6.8 discusses various ways you can load resources using the xrdb program. Section 6.9 shows how to list the resources for a client with appres.

--VQ and SJC



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.