The xrdb program saves you from maintaining multiple resource files if you run clients on multiple machines. It stores resources on the X server, where they are accessible to all clients using that server. (This property is also called the resource database.)
Place the appropriate xrdb command line in your .xinitrc file or .xsession file to initialize resources at login, although it can also be invoked interactively. It has the following syntax:
xrdb [options] [filename]
The xrdb client takes several options, all of which are documented on its manual page. We'll discuss the most useful options.
The optional filename argument specifies the name of a file from which the values of client variables (resources) will be read. If no filename is specified, xrdb will expect to read its data from standard input. Note that whatever you type will override the previous contents, so if you inadvertently type xrdb without a filename argument and then quit with CTRL-d, you will delete any previous values. (You can append new settings to current ones using the -merge option discussed later in this article.)
The resource filename can be anything you want. Two commonly used names are .Xresources and .Xdefaults.
You should load a resource file with the xrdb -load option. For example, to load the contents of your .Xresources file into the RESOURCE_MANAGER, you would type:
% xrdb -load .Xresources
% xrdb -query XTerm*ScrollBar: True bigxterm*font: 9x15 bigxterm*Geometry: 80x55 smallxterm*Font: 6x10 smallxterm*Geometry: 80x10 xterm*borderWidth: 3
If xrdb has not been run, this command will produce no output.
For example, let's say you wanted to add new resources listed in the file new.values. You could say:
% xrdb -merge new.values
As another example, if you wanted all subsequently run xterm windows to have scrollbars, you could use standard input and enter:
% xrdb -merge xterm*scrollBar: True
and then press CTRL-d to end the standard input. Note that because of precedence rules for resource naming, you may not get what you want automatically. For example, if you specify:
xterm*scrollBar: True
and the more specific value:
xterm*vt100.scrollBar: False
has already been set, your new, less specific setting will be ignored. The problem isn't that you used the -merge option incorrectly -- you just got caught by the rules of precedence.
If your specifications don't seem to work, use the -query option to list the values in the RESOURCE_MANAGER property, and look for conflicting specifications.
Note also that when you add new specifications, they won't affect any programs already running -- only programs started after the new resource specifications are in effect. (This is also true even if you overwrite the existing specifications by loading a new resource file. Only programs run after this point will reflect the new specifications.)
You don't need to edit the file manually (although you certainly could.) The -edit option allows you to write the current value of the RESOURCE_MANAGER property to a file. If the file already exists, it is overwritten with the new values. However, xrdb is smart enough to preserve any comments and preprocessor declarations in the file being overwritten, replacing only the resource definitions. For example:
% xrdb -edit ~/.Xresources
will save the current contents of the RESOURCE_MANAGER property in the file .Xresources in your home directory.
If you want to save a backup copy of an existing file, use the -backup option:
% xrdb -edit .mydefaults -backup old
The string following the -backup option is an extension appended to the old filename. In the prior example, the previous copy of .mydefaults would be saved as .mydefaults.old.
There is no way to delete a single resource definition other than to read the current xrdb values into a file. For example:
% xrdb -query > filename
Use an editor to edit the file, deleting the resource definitions you no longer want, and save the file:
% vi filename
Then read the edited values back into the RESOURCE_MANAGER with xrdb (note that we're replacing the values, not merging them, so we use -load):
% xrdb -load filename
--VQ and SJC
Copyright © 2003 O'Reilly & Associates. All rights reserved.