X Resources Syntax

The general syntax for settings in an X Resource file is:
    Client_Class*Sub_Classes*resourceName: value
For example, in the the setting
    Idl*XmFileSelectionBox*fontList: times-roman
Idl is the Client_Class, XmFileSelectionBox is a subclass, fontList is the resource and times-roman is the value (or attribute).

The '!' character introduces comments. In our XResources example some sample settings are "commented out". Remove the '!' characters to activate them. Resource names and values are case insensitive, but Client_Class and Sub_Class names are not. Other X Resource files may be included in-place with #include. For example, the line

    #include "Idl_cluster_tools"
in your $HOME/.Xdefaults or $HOME/Idl file would include the contents of $HOME/Idl_cluster_tools.

The Client_Class usually corresponds to the name of an application. For example, the Client_Class for the xterm application is XTerm; the Client_Class for IDL is Idl. However, be careful not confuse an application name with its Client_Class. A number of applications can use the same Client_Class. Client_Class X resource files are normally found in a directory named app-defaults. For example, system-wide Client_Class X resource files on Solaris are found in /usr/openwin/lib/X11/app-defaults. (on Linux and other flavors of UNIX, /usr/lib/X11/app-defaults) and system-wide Client_Class X resource files for IDL are found in $IDL_DIR/resource/X11/lib/app-defaults.

Resources are applied in order; later ones override earlier ones. Similarly, if the same resource setting appears more than once in the same file, the last one prevails. Hence, you can specify user-specific X resource settings for yourself in your $HOME/.Xdefaults file. (Or $HOME/.Xdefaults-hostname where "hostname" is the name of a machine where you have a login directory.) Note that X Resource settings in this file affect all X applications. Changes for one application here may have undesirable consequences on other applications, and changes to this file these will not take effect until your next login session.

You can also override the system-wide settings for a particular Client_Class by making a file with the same name in your $HOME login directory. For example, settings in $HOME/XTerm will override /usr/openwin/lib/X11/app-defaults/XTerm and settings in $HOME/Idl will override $IDL_DIR/resource/X11/lib/app-defaults/Idl. Changes to settings in these files take effect the next time you run an application that uses that and only that particluar Client_Class.

Classes are hierarchical and the sequence of classes in a resource setting follows a path down the hierarchy. An asterisk (*) in the path represents any sequence of classes in the hierarchy, including none. This is called "loose binding". A period in the hierarchy separates adjacent classes and must exactly follow the hierarchy. This is called "tight binding". In general it is easier to use loose binding because you do not have to know the exact hierarchy for each application.

For example, the background color for all IDL widgets can be set with:

    Idl*background: wheat
but the background color for just text widgets override it with:
    Idl*XmText*background: lightblue
Similarly, fonts used for all widgets can be set with:
    Idl*fontList: times-bold
but the font for just button widgets override it with:
    Idl*XmPushButton*fontList: helvetica

For the most part, casual users should only change settings that affect the "look and feel" attributes of application GUI components (called "widgets"), primarily colors, typographic fonts, and the geometry for default placement on the monitor. GUI Classes on UNIX systems usually have names beginning with "Xm" for X Windows Motif, which are also used by Sun Microsystems' OpenWindows (available also on Linux) and the Common Desktop Environment, aka CDE, used also by XConsortium members HP, IBM, and Sun. Useful (and safe) settings for other resources should be well documented in X resource file comments and examples provided by the application vendor.

X resources have no effect over attributes that are hard-coded in IDL programs, e.g.:

    Widget_Control, Default_Font='times-roman'

See also:

    $ man X11