Xresources
   HOME

TheInfoList



OR:

In the
X Window System The X Window System (X11, or simply X) is a windowing system for bitmap displays, common on Unix-like operating systems. X originated as part of Project Athena at Massachusetts Institute of Technology (MIT) in 1984. The X protocol has been at ...
, the X resources are
parameter A parameter (), generally, is any characteristic that can help in defining or classifying a particular system (meaning an event, project, object, situation, etc.). That is, a parameter is an element of a system that is useful, or critical, when ...
s of
computer program A computer program is a sequence or set of instructions in a programming language for a computer to Execution (computing), execute. It is one component of software, which also includes software documentation, documentation and other intangibl ...
s such as the name of the
font In metal typesetting, a font is a particular size, weight and style of a ''typeface'', defined as the set of fonts that share an overall design. For instance, the typeface Bauer Bodoni (shown in the figure) includes fonts " Roman" (or "regul ...
used in the
button A button is a fastener that joins two pieces of fabric together by slipping through a loop or by sliding through a buttonhole. In modern clothing and fashion design, buttons are commonly made of plastic but also may be made of metal, wood, or ...
s, the background color of
menu In a restaurant, the menu is a list of food and beverages offered to the customer. A menu may be à la carte – which presents a list of options from which customers choose, often with prices shown – or table d'hôte, in which case a pre-est ...
s, etc. They are used in conjunction with or as an alternative to
command line A command-line interface (CLI) is a means of interacting with software via command (computing), commands each formatted as a line of text. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user ...
parameters and
configuration file A configuration file, a.k.a. config file, is a computer file, file that stores computer data, data used to configure a software system such as an application software, application, a server (computing), server or an operating system. Some applic ...
s.


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 In botany, a tree is a perennial plant with an elongated stem, or trunk, usually supporting branches and leaves. In some usages, the definition of a tree may be narrower, e.g., including only woody plants with secondary growth, only ...
, 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 character In software, a wildcard character is a kind of placeholder represented by a single character (computing), character, such as an asterisk (), which can be interpreted as a number of literal characters or an empty string. It is often used in file ...
s 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 Xlib (also known as libX11) is an X Window System protocol client library (computer science), library written in the C (programming language), C programming language. It contains subroutine, functions for interacting with an X Server (computi ...
functions, it can only request the value of a specific resource. Contrary to most
database In computing, a database is an organized collection of data or a type of data store based on the use of a database management system (DBMS), the software that interacts with end users, applications, and the database itself to capture and a ...
s, 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.


Location and use

During X display server execution, the X resources are stored in two standard locations, depending on whether they apply to all screens or to a particular one: # the RESOURCE_MANAGER property of the root window of screen 0 # the SCREEN_RESOURCES property of the root window of an arbitrary screen X resources are stored in the server rather than in a configuration file to allow programs started from other computers to use them. Indeed, a program connecting to an X display server from another computer can access the resources via the
X protocol The X Window System core protocolRobert W. Scheifler and James Gettys: ''X Window System: Core and extension protocols, X version 11, releases 6 and 6.1'', Digital Press 1996, RFC 1013Grant EdwardsAn Introduction to X11 User Interfaces is the base ...
. Using the old system of storing program parameters in the .Xdefaults file creates the need of copying this file to all other computers where a program can be started. Resources are manipulated by the
xrdb xrdb (X resource database manager) is a program used for accessing the X resources of a server. Its main use is to read a set of resources from a file and store them in the server at startup. This program can access the resources in both read and ...
program. In particular, many X display server configurations run xrdb at start up, instructing it to read the resources from the .Xresources file in the user's
home directory A home directory is a directory (file systems), file system directory on a multi-user operating system containing computer file, files for a given user (computing), user of the system. The specifics of the home directory (such as its name and loc ...
. From this point on, every other program finds the resources in the two standard locations. You can view the current resources from a console with xrdb -query.


Client libraries

Xlib Xlib (also known as libX11) is an X Window System protocol client library (computer science), library written in the C (programming language), C programming language. It contains subroutine, functions for interacting with an X Server (computi ...
contains a number of
convenience function A convenience function is a non-essential subroutine in a programming library or framework which is intended to ease commonly performed tasks. These convenience functions may be added arbitrarily based on the creator's perception of what these meni ...
s for accessing the resources on the server and manipulating them locally. These functions are used both by xrdb and by every other program that needs these resources. Most of these functions manipulate a ''resource database'', which is a local data structure representing a set of resource specifications. The Xlib functions for resource management are: * functions for reading the resources on the server into a local string (XResourceManagerString and XScreenResourceString) * functions for creating, manipulating, and destroying a local resource database (XrmInitialize, XrmDestroyDatabase, XrmGetFileDatabase, XrmPutFileDatabase, XrmGetStringDatabase, XrmLocaleOfDatabase, XrmSetDatabase, XrmGetDatabase, XrmCombineFileDatabase, XrmCombineDatabase, XrmMergeDatabases, XrmParseCommand) * functions for looking up resources and storing new ones (XrmGetResource, XrmQGetResource, XrmQGetSearchList, XrmQGetSearchResource, XrmPutResource, XrmQPutResource, XrmPutStringResource, XrmQPutStringResource, XrmPutLineResource, XrmEnumerateDatabase) In particular, the function XrmParseCommand allow parsing the
command line A command-line interface (CLI) is a means of interacting with software via command (computing), commands each formatted as a line of text. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user ...
arguments, reading resources that are then added to a local resource database. This way, the resources can be read from the server and used as defaults that are overridden by command line arguments. For the sake of efficiency, integers called ''quarks'' are defined to represent local strings. Quarks are similar to
atoms Atoms are the basic particles of the chemical elements. An atom consists of a nucleus of protons and generally neutrons, surrounded by an electromagnetically bound swarm of electrons. The chemical elements are distinguished from each other ...
, but they represent strings stored locally rather than on the server. A number of Xlib functions create an association between strings and quarks. Quarks can be used in place of component names when using one of the above functions; resource names therefore correspond to quark lists.


See also

*
X Window System protocols and architecture In computing, the X Window System (commonly: X11, or X) is a network-transparent windowing system for bitmap displays. This article details the protocols and technical structure of X11. Client–server model and network transparency X uses a ...


References

{{Reflist


External links


Inessential X Resources for Techno-DweebsResource Manager Functions
of the
Xlib Xlib (also known as libX11) is an X Window System protocol client library (computer science), library written in the C (programming language), C programming language. It contains subroutine, functions for interacting with an X Server (computi ...
client library X Window System