"Xterm" or "xterm" in configuration file

After starting to use Arch I switched to xterm and urxvt terminal and enjoyed the flexibility of them (esp. scaleHeight resource). However, I don’t understand why sometimes configs work with Xterm and sometimes with xterm or XTerm (lower vs upper case x and t).

For example, I have this odd config that is working on Ubuntu:

XTerm*faceName: terminus
XTerm*faceSize: 11
XTerm*saveLines: 16384
XTerm*loginShell: true
XTerm*charClass: 33:48,35:48,37:48,43:48,45-47:48,64:48,95:48,126:48
XTerm*termName: xterm-color
XTerm*eightBitInput: false
xterm*VT100.geometry: 100x80    ! <------ this line would not work with "Xterm" or "XTerm"
XTerm*scaleHeight: 1.3          ! <----- but all others work with "XTerm"

However, my Arch box runs on “xterm” fine. The same is true for URxvt terminal: I can’t simply port my Arch .Xresources to Ubuntu14 work box because parts of it stop working, and I get different setups after running:

xrdb -merge .Xresources

X.org on xterm did not have any examples (searching for “xterm*” did not return anything on that page). I see examples with Xterm, xterm and XTerm online… It baffles me that the config above works since it is syntactically off. Why is this the case? Does it maybe have something to do with new or old resources in X? Thanks!

xterm on ubuntu is Xterm(297). I don’t have access to my Arch box at the moment, but it would be pretty up-to-date. I don’t know how to tell Xterm version from Arch’s repos, but maybe this: https://www.archlinux.org/packages/extra/i686/xterm/
So, if that link is right, then yes, I am running different Xterm versions.

I tried upgrading xterm, but it is still 297.

apt-get update && apt-get install --only-upgrade xterm

I can’t do it now, but I might try to recompile the latest version to see if the issue is there.

Following the suggestions by ILMostro_7 below I tried XTerm.vt100.geometry, which still did not work. This is Xterm (297) on Ubuntu14. So basically, . or * it seems to only work with little xt.

Result of appres XTerm xterm | grep geometry thanks to Gilles. I did not think to look up what exactly xrdb -merge does which resulted in this mess. So my guess is that one of these takes precedence over everything else?

xterm.VT100.geometry:   100x100
xterm*VT100.geometry:   100x80
xterm*VT100*geometry:   50x50
xterm.vt100.geometry:   160x40
xterm*vt100.geometry:   100x20
xterm.geometry: 5x5
xterm*geometry: 100x20
XTerm.VT100.geometry:   100x100
XTerm*VT100.geometry:   50x50
XTerm*VT100*geometry:   20x10
XTerm.vt100.geometry:   100x5
XTerm*vt100.geometry:   40x40
XTerm*geometry: 50x50

In fact it looks like xterm.vt100.geometry: 160x40 takes precedence over other ones since that the instance I keep getting. Also, I somehow managed to completely screw up Xterm menues (Ctrl+mouse click) – they show up as a small yellow line. Hehe

Asked By: Serge Poele


X11 resources have a name which consists of a series of components separated by a dot, such as xterm.vt100.geometry. The first component is the name of the application, the second component is a widget in that application, and the last component is a property of the widget. Widgets can be nested, so there can be more than three components, or just two for a property of the application.

Specifications of X resources can apply to a single resource or to a set of resources matching a pattern. There are two ways to make a specification apply to multiple resources.

  • You can use a class name instead of an instance name for any component. Conventionally, instance names start with a lowercase letter while class names start with a capital letter.

    • At the application level, the class name is usually fixed for a given application, typically to the capitalized application name, and sometimes other letters are also in uppercase, e.g. XTerm, XCalc, GV, NetHack, … Applications using the X toolkit support an option -class to set the class name, as well -name to set the instance name (which defaults to the base name of the executable). For example XTerm.vt100.geometry sets a value of the geometry property for the vt100 widget of any instance of the XTerm class; it applies to xterm -name foo but not to xterm -class Foo.
    • At the widget level, there can be multiple widgets with the same class, for example multiple buttons in the same window. Xterm has a single widget of class VT100, called vt100, which is the terminal emulator part that covers the whole window. Other widgets include the menus mainMenu, fontMenu and vtMenu of class SimpleMenu.
  • There are wildcards: ? means “any widget”, and * means “any widget sequence”. For example xterm*background defines a background for absolutely everything inside the Xterm window.

You can explore the resource tree of an application that supports the editres protocol with editres. Few applications support this protocol, but Xterm is one of them.

It’s possible for a given resource to be matched by multiple patterns. In this case, precedence rules apply. See the manual for the full rules.

In your case, it’s likely that there’s another entry somewhere that is a closer match for xterm.vt100.geometry than xterm*VT100.geometry, and that match is overriding your setting. The others have no other setting so whatever you do wins.

Some of the comments, etc., are not accurate. By the way, the description of X resources is in the X(7) manual page, in the section titled Resources. That’s the best place to start reading, and there’s little point in repeating it here.

Here’s some points overlooked:

  • resource names are case-sensitive: XTerm is not the same as Xterm is not the same as xterm, etc.
  • conventionally X resource names use a leading capital letter for class name.
  • when the first letter of the class name is X, there’s a convention to make the second letter capitalized. So we get XTerm. Other examples include XCalc, XClock, XConsole, XLoad, XLogo.
  • on the other hand, we have Xedit (lowercase e), Xfd, Xmag, Xman, Xmessage, Xvidtune. So the convention is not a rule.
  • X Toolkit applications (such as xterm) use XtOpenApplication or XtAppInitialize to initialize their application-resources. Those calls take an instance and class name.
  • conventionally, the instance name is the actual name of the program (its filename). If you happen to rename the program (as happens occasionally, e.g., xterm.real) that changes the name. The program doesn’t have to do this, but it’s done often. xterm does it.
  • usually the class name is a constant. It is not in xterm, because it expects one of two classes: XTerm or UXTerm (3 leading capitals). The latter is used for the uxterm script, simplifying the way the fonts are specified. This dates from 2000, making it about midway in X’s history. A quick check of the 30 programs in the X source tree from the early/mid-2000’s which use XtAppInitialize doesn’t show any other programs using a variable for the class name.
  • the -class option is xterm-specific. Actually dbedizzy accepts a -class option, for the visual class. That’s different. X Toolkit has no such option. There’s a list of the common options for X Toolkit in the X(7) manual page in Options. The xterm manual presents those in more detail, in X Toolkit Options.
  • editres, as its manual page indicates, works for any program using the X Toolkit. There’s 36 programs in the X source-tree using one or the other of the two initialization calls mentioned, so it’s not “few programs” to which this would apply.
  • on the other hand, xterm is one of the few for which editres is not very useful. It has too many resource settings.

The app-defaults files which are installed for xterm and other applications conventionally specify their resource-settings beginning with asterisk (*). That makes them independent of the instance name. An asterisk matches any number of levels of the widget hierarchy, which is often a source of confusion, e.g., the xterm FAQ Why are the menus tiny?, where it is possible for a geometry resource intended for the VT100 widget to be (mis)applied to the menus. There are similar problems with too-generous matching applied to the font resource. The fix for both is to use more-specific matches, referring to the VT100 widget (specific), using dot (.), etc.

Because the app-defaults files avoid unnecessary use of '.', they are relatively easy to override in your own configuration. If you have trouble getting a resource such as

xterm*VT100.geometry: 100.80

to apply, there’s only a few places to look:

  • if you used that pattern before, it’s already used, and setting it again (later in your resource-files) will not affect the value used.
  • a more-specific setting such as xterm.VT100.geometry overrides less-specific ones using wildcards * and ?.
Answered By: Thomas Dickey
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.