Home Liberties Xubuntu Mirrors Shop Links Contact

Xubuntu HOWTO

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

General

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
Name of the application.

class
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

WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW
_NET_WM_ICON_GEOMETRY(CARDINAL) = 665, 765, 162, 3
WM_STATE(WM_STATE):
                window state: Normal
                icon window: 0x0
_NET_WM_ALLOWED_ACTIONS(ATOM) = _NET_WM_ACTION_CLOSE, _NET_WM_ACTION_MAXIMIZE_HORZ, _NET_WM_ACTION_MAXIMIZE_VERT, _NET_WM_ACTION_CHANGE_DESKTOP, _NET_WM_ACTION_STICK, _NET_WM_ACTION_SHADE
_NET_FRAME_EXTENTS(CARDINAL) = 4, 4, 24, 4
_NET_WM_DESKTOP(CARDINAL) = 2
_WIN_WORKSPACE(CARDINAL) = 2
_WIN_STATE(CARDINAL) = 4
_NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_VERT
WM_LOCALE_NAME(STRING) = "C"
WM_CLASS(STRING) = "rxvt", "XTerm"
WM_HINTS(WM_HINTS):
                Client accepts input or input focus: True
                Initial state is Normal State.
                window id # of group leader: 0x3800003
WM_NORMAL_HINTS(WM_SIZE_HINTS):
                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_CLIENT_MACHINE(STRING) = "localhost"
WM_COMMAND(STRING) = { "rxvt" }
WM_ICON_NAME(STRING) = "rxvt"
WM_NAME(STRING) = "rxvt"
    

resource
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.


value
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$