Getting the Most Out of X Resources
Do you ever wonder how some peoples' xclocks and xterms always start up with different colors than boring old black and white? Do you wish those Athena 3-D widgets (discussed in Linux Journal, issue 15) looked a bit more like the Motif ones they are supposed to emulate? Through the magic of something called X Resources, you can make all this happen—and a lot more.
Resources may look confusing and complex at first glance, like something only a programmer with a mean streak would foist upon the unwitting user. It's true that resources are very closely tied to X programming, which is why they can appear so arcane. However, with a little practice, you can customize applications to suit your own personal preferences, and kiss “vanilla X” goodbye forever.
Color has already been mentioned, but to dismiss resources as a simple color control mechanism would be a mistake. Don't like an application's choice of fonts? Change them. Want to change the way the cursor appears? You can do that too.
Resources can even be used to modify the entire behaviour of an application, from the appearance and labels of buttons and pull-down menus, to the actual functions that these items call in the program. For instance, if you think that the “Quit” label on a button is too bland, you can easily substitute “Kill”, or something even more imaginative.
X Resources are stored in several locations. Applications often have a default set of resources that are stored in a file in the /usr/lib/X11/app-defaults directory. For example, you will find resource files for both xterm and xload in that directory. Notice the files usually have the first two letters capitalized, i.e. XTerm, and XLoad. While this is only a de-facto standard, it is related to the applications class name, which we'll get to later.
Besides these application-specific files, there are two other files in which you can store resources. If you have a file in your home directory called .Xdefaults, it will be loaded when your X session starts (either through xdm or startx), replacing any system-wide resources that might have been defined (stored in /usr/lib/X11/Xdefaults). A second file, .Xresources, doesn't replace the system defaults but instead is merged with them. For that reason, you probably want to use this file for your own resources instead of .Xdefaults.
Resources are specified in one of the following formats:
name*variable: valuename.variable.variable: value
Resources are case sensitive, and you should be sure that there is at least a space or a tab after the colon, before the value specified. The first format listed, which utilizes the * separator (called loose binding), is used to indicate that all resources of a program with name name and variable variable are to acquire value value. For instance, the resource
Xedit*font: 7x14
will cause xedit to use a 7x14 fixed font for everything, including the main window and the menus. (We will see how to find resource names later in the article—take them on faith for now.) But what if you only want to change the font in a particular area of a program? In that case, the . notation (called tight binding) would be used. This notation allows you to be more specific than loose binding allows:
Xedit.Paned.Label.font: fixed
will make two labels in xedit use the fixed font. However, the default font (7x14, as set by the first resource) will be used everywhere else. Note that although the first resource applies to every font resource in the Xedit program, including those two labels, the second resource is the one used for those labels because it is more specific. More specific resources are always used in preference to less specific resources.
Resources, and the widgets they modify, have a hierarchical nature. “What's a widget?” you ask. Widgets are the basic building blocks, or objects, of X programs. Some example widgets with which everyone is familiar: scrollbars, text-entry fields, buttons, and checkboxes. In the above resource, the Label widget is a “child” of the Paned widget, which is a “child” of Xedit. This will become more clear when the editres program is introduced below.
One other note before we continue: a distinction must be made between classes and instances of a particular class. In the above resource, Label specifies any instance of the widget class Label. There are two that match the specification, whose names are bc_label and labelWindow. All classes begin with a capital letter by definition; Label is the class, and bc_label and labelWindow, which start with lower case letters, are the instances of that class.
You can specify instances as well as classes, so that only one particular widget is affected; you can add the following resource:
Xedit.paned.bc_label.font: 7x14
which will set the font for one of the two Label widgets back to 7x14—it is more specific than the previous resource.
It is usually more convenient to set the resources for an entire class of widgets than for an individual instance, as you typically want to make the entire application look consistent.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- A Topic for Discussion - Open Source Feature-Richness?
- RSS Feeds
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Validate an E-Mail Address with PHP, the Right Way
- Readers' Choice Awards
- Tech Tip: Really Simple HTTP Server with Python
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




22 min 18 sec ago
2 hours 45 min ago
2 hours 49 min ago
2 hours 50 min ago
7 hours 15 min ago
9 hours 6 min ago
14 hours 19 min ago
17 hours 30 min ago
19 hours 46 min ago
20 hours 14 min ago