Graphical Environment  «Prev  Next»
Lesson 2 X resources and classes
Objective Explain how resources are organized into classes.

X resources and Classes

Question: Do X resources for the Red Hat graphic user interface still exist?
As of September 2021, the X resources still exist for the Red Hat graphic user interface.
X resources provide a flexible and powerful way to customize the behavior of X clients such as terminal emulators, window managers, and the X server itself. These resources are typically specified in a configuration file known as the .Xresources or .Xdefaults file in a user's home directory. This file contains a series of resource specifications, which are essentially key-value pairs that control aspects of the behavior and appearance of X clients.
For instance, you might specify the default font for a terminal emulator, the color scheme for a window manager, or the DPI setting for the X server. The syntax of the resource specifications is fairly straightforward. Each line of the file contains a resource name followed by a colon and the value of the resource. Here's an example for the XTerm terminal emulator:
XTerm*font: Monospace 12
XTerm*background: black
XTerm*foreground: white

This tells XTerm to use a 12-point Monospace font and a black background with white foreground text.
On Red Hat systems, the X resources are read when the X server starts up. If you make changes to your .Xresources or .Xdefaults file, you can use the xrdb command to merge the changes into the running X server:
xrdb -merge ~/.Xresources

Note that some desktop environments and window managers have their own ways of managing settings and may not use X resources, or may use them in conjunction with other configuration systems. For instance, GNOME primarily uses the GSettings system, but it also reads the .Xresources file for certain settings. Therefore, depending on your particular setup, you may or may not find X resources to be the most effective way to customize your user interface.

Default preferences in X

To promote a uniform look to the GUI, X allows you to set default preferences for options such as color and border thickness. These preferences are held in your X resources. The X server loads your resources and displays windows according to your settings.

X Applications and Classes

It is important to understand how X structures resources because the relationship between applications and classes is crucial to setting your X resources. The X Windows System places X applications into specific classes. When you specify class resources, X modifies the preferences for all applications in that class. For example, you can set the background color for the term class and all applications in the term class will use that preference.
An application's class is usually the base application's name with the first letter capitalized. For example, the xterm program, a member of the Xterm class, is the base application for all X Windows terminals. Xterm derivatives include kterm, nxterm, and rxterm; these programs all perform a similar function as xterm, but in different ways. Therefore, the class of all X terminals is Xterm, as illustrated in the graphic below

The relationship between X applications and classes
The relationship between X applications and classes
You can increase your productivity and your GUI's uniformity by keeping this scheme in mind when you create a set of resources. For example, you will save yourself a lot of time if you set your preferences for an entire class of applications, rather than setting them one by one.

X Server

The basic desktop is provided by the X.Org X server. The X server provides the framework on which GNOME, KDE, and other desktop applications and window managers rely. If you have used the XFree86 X server in other Linux distributions, special features of the server described later in this module might interest you. This module takes you on a tour of your desktop, going through the process of logging in, trying out some features, and customizing how your desktop looks and behaves. Sections on KDE, GNOME, and Xfce desktops contain reference information on how to set preferences, run applications, configure panels, and work with the file managers. The last section describes how to use the Display Settings window to configure your video card and monitor, if they were not properly detected. Given the right video card and monitor, you can enable AIGLX desktop effects. With AIGLX, you can get interesting desktop effects, such as windows that wobble when you move them or changing workspaces on a revolving cube.
The next lesson shows you how to use the .Xdefault file to customize the look and feel of X applications.