I'm looking for a way to automatically list all X resources that are used in an application. To give you an example, for xterm I'd expect a list similar to the following but with all the resources that are used by xterm.


The method can work on the source code of the application but if it is possible to do it with only the application binary that would also be interesting.

3 Answers 3


You can explore the resources of an existing window with editres. That's an interactive program, which lets you browse the resource tree, and find the location of a widget in that tree by clicking on the widget in the application. You can even modify a resource if the application supports it. That, however, requires that the application supports the Editres protocol, which is not so common even amongst the dwindling proportion of applications that use X resources. Furthermore, the GUI editres client is the only application I know of that knows how to send Editres queries, so no command line listing.

You can see what resource settings are defined for a particular application with appres. The application might support other settings. That's different from xrdb -query which only list settings that the user has explicitly overloaded (appres also lists system defaults).




It is quite easy to 'caputure' the XrmParseCommand function and listing the options before executing the original function.

/* G. Allen Morris III <[email protected]> */

#define _GNU_SOURCE

#include <X11/Xresource.h>
#include <stdio.h>
#include <dlfcn.h>

static char *types[] = {

void XrmParseCommand(XrmDatabase * database,
                     XrmOptionDescList table,
                     int table_count,
                     _Xconst char *name, int *argc_in_out, char **argv_in_out)
    void (*original_XrmParseCommand) (XrmDatabase * database,
                                      XrmOptionDescList table,
                                      int table_count,
                                      _Xconst char *name, int *argc_in_out,
                                      char **argv_in_out);

    int argc = *argc_in_out;
    printf("'XrmParseCommand's %s\n", name); 
    for (int i = 0; i < table_count; i++) {
        switch (table[i].argKind) {
        case XrmoptionNoArg:
        case XrmoptionIsArg:
        case XrmoptionStickyArg:
        case XrmoptionResArg:
        case XrmoptionSkipArg:
        case XrmoptionSkipLine:
        case XrmoptionSkipNArgs:
        case XrmoptionSepArg:
            printf("%20s %30s %s \n", types[table[i].argKind], table[i].option,
            printf("%20s %30s %s \n", "UNKNOWN", table[i].option,
    original_XrmParseCommand = dlsym(RTLD_NEXT, "XrmParseCommand");
    (*original_XrmParseCommand) (database,
                                 table_count, name, argc_in_out, argv_in_out);
/* eof */


myXrmParseCommand.so : myXrmParseCommand.c
        gcc -Wall -fPIC -shared -o $@ $< -ldl

To run it

make && LD_PRELOAD=./myXrmParseCommand.so  xterm -e :;

There is a snippit on Git lab here.

  • That shows the requested patterns, but not the actual widget hierarchy. Nov 18, 2018 at 18:40
  • This is EXACTLY what I am looking for Apr 11, 2020 at 14:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .