X Resources - Format

Format

At the X protocol level, resources are strings that are stored in the server and have no special meaning. The syntax and meaning of these strings is given by client libraries and applications.

Every X resource specifies a parameter for a program or one of its components. A fully specified resource has the following format:

application.component.subcomponent.subcomponent.attribute: value

This resource specifies the value of attribute for the component named component.subcomponent.subcomponent of the program application. Resources are often used for specifying the parameters of widgets created by the application. Since these widgets are arranged in a tree, the sequence of component/subcomponent names is used to identify a widget by giving its path within the tree. The value of the resource is the value of an attribute for this widget, such as its background color, etc.

X resources are also used to specify parameters for the program that are not directly related to its widgets, using the same syntax.

X resources are designed to allow the same parameter to be specified for more than one program or component. This is realized by allowing wildcard characters in a resource specification. In particular, the ? character is used to match the application name or a single component. The * character is used to match any number of components. These two characters can be used anywhere but at the end of the resource name. In other words, an attribute cannot be replaced by a wildcard character.

While the resources can be loosely specified via the wildcard characters, queries for the value of a resource must specify that resource exactly. For example, a resource can specify that the background of every component of the xmail program must be red:

xmail*background: red

However, when a program (e.g., the xmail program itself, when it wants to find out which background color to use) accesses the resource database via Xlib functions, it can only request the value of a specific resource. Contrary to most databases, the stored data can be specified loosely (via wildcard characters), but the interrogation cannot. For example, a program can query for the value of xmail.main.background or of xmail.toc.buttons.background, but cannot use ? or * to check the background color of several components at once.

Resources can also be specified for classes of elements: for example, application.widget.widget.attribute: value can be generalized by replacing the application name with its class (e.g., Mail instead of xmh), each widget with its type (Pane, Button, etc.), and the attribute with its type.

Read more about this topic:  X Resources