Home Liberties Xubuntu Mirrors Shop Links Contact

Xubuntu HOWTO

Set default options for X applications by configuring the ~/.Xdefaults file


In order to set default options for applications and avoid having to specify them on the command line, the .Xdefaults file can be used, which is located in user's home directory. Each X application has numerous options (called resources) which can be set. Some of these include reverse video, window size, window location, and many others. When set, these options are loaded every time an application is started. .Xdefaults follows the following format:

name.class.resource: value

Name of the application.

Used for grouping resources together. For example, the class Geometry contains all the resources which affect the geometry of any of the application's windows. For instance, xterm uses the resources geometry for the size and location of the window: iconGeometry for the size and location of the icon and tekGeometry for the size and location of the Tek window. All of these are members of the class Geometry. The purpose of a class is to allow the user to set things more easily. If you set a class to a given value, then all the individual resources in that class will be set to it, just as if you set them individually. Therefore you can set all three xterm geometries individually, or if you wanted them all to be the same you could just set the Geometry class. The names of classes conventionally start with an upper-case letter.

Classes which are understood by each application program are described in the manual entry for that program or you can use the xprop tool. Simply start up the X program in question, type xprop in a terminal, then click in the window of the X program. This will give you the class and instance of the program along with all sorts of other useful information. For example, using xprop on an rxvt window gives:

% xprop

_NET_WM_ICON_GEOMETRY(CARDINAL) = 665, 765, 162, 3
                window state: Normal
                icon window: 0x0
WM_CLASS(STRING) = "rxvt", "XTerm"
                Client accepts input or input focus: True
                Initial state is Normal State.
                window id # of group leader: 0x3800003
                user specified location: 75, 0
                user specified size: 844 by 754
                program specified minimum size: 12 by 19
                program specified resize increment: 8 by 15
                program specified base size: 4 by 4
                window gravity: NorthWest
WM_COMMAND(STRING) = { "rxvt" }
WM_NAME(STRING) = "rxvt"

Indicates the name of some resource whose value can be changed. Some resources include foreground (the foreground color), background (the background color), geometry (the size and location of the window), scrollBar, (whether or not scrollbars should be used) et. The names of resources conventionally start with a lower-case letter. Each application program has a different set of resources which you can modify; they are described in the manual entry for the program.

Note on class and resource names: Capitalization is used to distinguish class names from resource names. Class names always begin with a capital letter, while resource names always begin with a lowercase letter. Note however that if a resource name is a compound word (such as cursorColor), the second word is capitalized.

A useful tool for obtaining resource names from many application is with the editres tool. Simply run editres, select CommandsGet Tree from the menu, and editres will gather information about that application and display it.

can be set to one of three types:
  • Integer (a whole number)
  • Boolean (on/off | yes/no | true/false)
  • String (sequence of characters, e.g., a pathname or window title)

$Xubuntu HOWTO: Set default options for X applications; v0.1.1; 16.04.2008$

del.icio.us tag it digg it sphinn facebook technorati slashdot

Boycott Trend Micro

submit to reddit

$xubuntu HOWTOs; v1.1.7; 03.12.2008$