Piter Punk's HomePage - English Version
 

Using .Xdefaults

Author: Piter PUNK Translator: Leonardo Azevedo
Translation revised by Carlos

In previous articles we placed some changes in .Xresorces or .Xdefaults files. But what are these files exactly? What are they for? What can they change?

1 Introduction

Almost every X application have resources and configuration options. Usually, these options do not need to be passed as parameters to the commands we call on the shell prompt. We can put them all together in .Xdefaults.

2 Xdefaults

The basic idea behind this file is to provide some of the applications configurations whitout filling your $HOME with hidden config files. Also, many command line options can be customized. For example: if you allways call 'rxvt' whith these options:

	$ rxvt -ls -bg black -fg white

You can save a lot of typing by configuring .Xdefaults to "complete" these options automatically putting this lines in .Xdefaults:

	Rxvt*background: Black
	Rxvt*foreground: White
	Rxvt*loginShell: True

We say then that these are the default configurations of 'rxvt'. So, every time you execute rxvt it will use these options (unless you specify the opposite in the command line).

That is why this file is called .Xdefaults! And, as it also configures the application's X resources, it can be also named as .Xresources. You do not need both files, only one will do (.Xdefaults would be better). In case it does not exist in your $HOME, just create it.

3 Which resources?

This is a very common question. Hardly we know all the resources an application has or where we can find them. But you have some options to sort this out ...

One of them is to check if the application is listed in /etc/X11/app-defaults. The standard resource configurations of your sistems are in this directory. So, it is enough to "cat" the file corresponding to the application you want to configure and check for the offered options.

Another options is to use the 'editres', which is a program made exactly for checking and editing an specific application's resources. For that, you run 'editres', click in "Commands", then in "Get Tree" and the last click is in the application which you want to see the resources for. In case the application is compatible with 'editres', a tree with all the application options will show up.

The last chance you have, is to see the 'man' of the rebel application. With some luck, the options will be in the man page. This is the 'aterm' case. And, as 'aterm' is very wealthy in options, it is a great idea to use .Xdefaults for your prefered configuration. -;)

4 How to edit it

It's been said already, but a reminder costs nothing ... If you don't have the .Xdefaults file in your $HOME, just create an empty one and then put the lines you consider apropriated in it.

When editing the file, if you do not want to forget what each line is for, you can make comments. On the contrary of many configuration files, comments begin with an exclamation point ("!") in .Xdefaults. And not the famous "#".

Let's supose you've already researched and know what resources you want to configure. So, we will show the sintax of the file only.

First, there are resources' Classes. For example: XTerm is the name of one of the classes. The XTerm itself and some of its derived apps (rxvt, aterm, wterm, etc ...) take this name for the class. Each class (in theory) is an application.

The resource tree comes afterwards. A dot (.) is the separator in the resource tree, in the same way a slash (/) is in the directory tree. The only problem is that it can lead to very big lines. The "*" as a wildcard is used to solve this problem. So the line:

	*numeric: C

indicates to all the applications that has any resource terminating whit "numeric" that this resource should be set to "C". So it is very common to find "*" in the middle of some lines.

In the example files in /etc/X11/app-defaults, all lines (or, at least the majority of them) begin with an "*". This happens because the name of class is specifyed by the name of the file itself.

This means that a line in the file /etc/X11/app-defaults/XTerm that looks like:

	*SimpleMenu*Cursor: left_ptr

when put in your .Xdefaults should look like:

	XTerm*SimpleMenu*Cursor: left_ptr

One last tip: .Xdefaults is VERY case sensitive. So, pay atention to the capitalization on the lines you want to copy.

You must restart the X server in order to your modifications take place. If you want your modifications to take place without restarting X, just type "rxdb .Xdefaults" and restart the application in question.

5 Conclusion

With this article, you learned what the .Xdefaults file is for and what to do with it. There are many interesting configurations that can be achieved with this file. some of this configurations are in my articles (as in "Fixing Netscape" and "XDM").

As always, we are prepared to answer for questions and take suggestions. The email is piterpk@terra.com.br.


Links Principal Artigos Piter Punk Dicas Programas
 
Powered by Slackware Linux - Written in VIm (the best one!)