CERN Accelerating science

This website is no longer maintained. Its content may be obsolete. Please visit for current CERN information.

next up previous
Next: Paperless Publishing with Up: Tutorial Section Previous: Tutorial Section

Setting X Window Resources on POSIX-based Systems

  Nicole Cremel CN/ASD and Alessandro Miotto CN/DCI

We will restrict ourselves to X Window applications which are based on the X Toolkit Intrinsics (the more usual case), and not to applications using directly Xlib (like tk/tcl applications for instance), for which the ``resource setting'' mechanism does not obey to any fixed rules.

In X11R5 and for POSIX-based systemsgif, the resource database is constructed when an application is launched by consulting the following sources of resource settings, in the order shown below. If a specification applies to a particular resource in more than one of these locations, then the first one in the list has priority (no override). The order of priority in resource setting is:

Command line options bound to resources through an option table passed to XtAppInitialize() (called in the application main program).

E.g. as -sb in xterm is bound to *scrollBar, a -sb or +sb in the command line would apply independently of any other setting.

N.B. All application written with the X Toolkit Intrinsics accept the options described in the X manual page. Additional options, but generally limited to a small subset of resources, may be added by the application programmer, on a per-application basis.

Resources specified explicitely with the -xrm option on the command line.

``Per-screen'' specifications stored in the SCREEN_
RESOURCES property are merged. The property can be set by the user using xrdb -load -screen (and displayed with xrdb -query -screen).

Resources contained in the ``screen-independent'' RESOURCE_MANAGER property gif can be set by the user using xrdb -load -global (and displayed with xrdb -query -global. Note that when there is only one screen SCREEN_RESOURCES is normally not used.

If the RESOURCE_MANAGER property does not exist (command xrdb -query -global gives nothing), then the contents of the file $HOME/.Xdefaults is used insteadgif.

N.B. X11R5 introduced the file .Xresources whose contents are read by xrdb in the Xsession startup file. Nevertheless, it is up to the Xsession scripts to have explicitely a line like xrdb -load $HOME/.Xresources (which will be the case at CERN with the HEPiX scripts for a ``Common X Environment''). Also, as it is not mentionned whether .Xresources is loaded with the -global or -screen flag, it can make a difference whether the file .Xdefaults is used or not (if -global is used then .Xdefaults is ignored and .Xresources used instead).

The user specific ``app-defaults'' file is searched calling XtResolvePathname() with the path Macros are substituted as follows:
%N -- application class namegif.
%T -- type
%S -- suffix
%L -- language
%l -- display language
%t -- display territory
%c -- display codeset

The application ``app-defaults'' file is searched calling XtResolvePathname() with the path specified by XFILESEARCHPATH, if defined, and type (%T), otherwise a system specific path (defined when building the X libraries) is usedgif (typically /usr/lib/X11/app-defaults).

E.g. the files /usr/lib/X11/app-defaults/XLock or /usr/lib/X11/app-defaults/Mwm set up system-wide resources for the X application xlock and the .

For more precise information from a programmer's point of view type man XtResolvePathname (this manual page is available a least on HPs).

If no ``app-defaults'' is located, any fallback resources registered by the application with XtAppSetFallbackResources() are used. (It is the way, for the application programmer, to set-up default values that seem to be the most suitable for a given application, without the user having to do anything, usually for a restricted list of resources.)

Notes: These notes are comments pointed out by various users. We put them here just for information.

HP does not use $HOME/.Xdefaults because all resources are set in the RESOURCE_MANAGER rather than SCREEN_RESOURCES property, which is not what every other platform does, but it is consistent with the standard.

Only the first resource file found in XFILESEARCHPATH and XUSERFILESEARCHPATH is used.

Sun oddly uses /usr/lib/X11/app-defaults as default directory when XFILESEARCHPATH is not defined (instead of /usr/openwin/lib/app-defaults).

We must add for completeness that the environment variable (XENVIRONMENT) may also be defined to override screen or global resources, using a file rather than the command line. But as its use is redundant when the user has full control over them (i.e. if xrdb sources the .Xresources file at session startup, as done in the HEPiX scripts) we will recommend, at CERN, not to use this variable.

next up previous
Next: Paperless Publishing with Up: Tutorial Section Previous: Tutorial Section

Janne Saarela
Fri May 19 16:03:15 METDST 1995