Inspect X Window Properties with xprop Without Guessing

When a window ignores the window manager or an app refuses to report its own title, xprop is how you stop guessing and read the actual X properties. You will inspect a clicked window, target one that is not easy to click, watch a property change, and read a font property. The same workflow helps with stubborn window-manager behaviour, desktop integration and X11 application debugging.

The examples match xprop 1.2.6 from Debian package x11-utils 7.7+6build2, installed on this machine. Allow about fifteen minutes. You need an X session and the x11-utils package. These are ordinary, read-only checks unless a step is explicitly marked as changing a property.

Checkpoint: Stop after the first command that gives you the information you need. xprop can print a great deal of data, and a large dump is often harder to reason about than one named property.

1. Confirm the display and installed version

xprop connects to the X server named by DISPLAY. Check that the variable points at the session you intend to inspect, then confirm the package version:

$ printf 'DISPLAY=%s\n' "$DISPLAY"
$ dpkg-query -W -f='${Package} ${Version}\n' x11-utils
x11-utils 7.7+6build2

The package version is distribution-specific. The program's own manual identifies this build of the utility as xprop 1.2.6. If DISPLAY is empty or points at another session, fix that before troubleshooting a window. Do not copy a display value from an untrusted source: access to an X server can expose or control applications in that session.

Checkpoint: If a later command says it cannot open the display, this is the first thing to recheck. A remote shell may need X11 forwarding, and a graphical login may use a different display or authorisation cookie.

2. Inspect one visible window

Run xprop without a target option and it presents a crosshair cursor. Click the window you want to inspect. With no property names, it prints every property on that window:

$ xprop
_NET_WM_NAME(UTF8_STRING) = "Example window"
WM_CLASS(STRING) = "example", "Example"
WM_NORMAL_HINTS(WM_SIZE_HINTS):  ...

The exact properties and values are host-specific, so treat those lines as the shape of the output rather than a result to paste literally. A property line normally contains the property name, its type in parentheses, and its value. The type is useful: UTF8_STRING, STRING, atoms and numeric fields need different interpretations.

For a smaller result, name the property after the target options. For example:

$ xprop WM_NAME
WM_NAME(STRING) = "Example window"

If the property is absent, xprop reports not defined. That is not necessarily an error. Applications do not all set the same properties, and a window may use _NET_WM_NAME rather than the older WM_NAME.

3. Target a window by ID or name

Clicking is inconvenient for an unmapped, obscured or fast-changing window. Use xwininfo to obtain an ID, then pass that ID to xprop. Both commands are read-only:

$ xwininfo
# click the target window, then copy the id from the report
$ xprop -id 0x200007 WM_CLASS WM_WINDOW_ROLE

The hexadecimal ID above is only an example. Replace it with the ID reported by your own X server. xprop accepts a decimal ID or a hexadecimal ID beginning with 0x. If the window disappears before the second command, obtain a fresh ID.

You can select a named window with -name:

$ xprop -name xclock WM_HINTS

This depends on the target having the name you supplied, and multiple windows can make name-based selection less clear. Use -root for the root window, which is useful for desktop-wide properties or the cut buffer:

$ xprop -root -len 100 CUT_BUFFER0

-len limits the number of bytes read and displayed for a property. Keep that limit when inspecting potentially large text. It prevents a diagnostic command from filling your terminal with an unexpected cut buffer.

4. Reduce noise and control formatting

By default, xprop displays a property's type. Use -notype when another tool or a quick comparison only needs the value:

$ xprop -notype -id 0x200007 WM_CLASS
 = "example", "Example"

The output depends on the property's format. For standard properties, xprop has built-in formats, so you normally do not need to write one. To ask for a specific format, put the format before the property name. This example reads a window ID as hexadecimal:

$ xprop -id 0x200007 32x _NET_CLIENT_LIST

Format strings describe the field size and field type. The useful basic characters are s for an 8-bit string, i for a signed integer, c for an unsigned number, x for hexadecimal and a for an atom. A format is easy to get wrong, so start with xprop's default output and only add a format when you know the property's representation.

For repeatable custom formats, use -f. Its arguments are the atom or property name, the field format and optionally a display format:

$ xprop -f POINT_SIZE 32i ' = $0\n' -font fixed POINT_SIZE

The $0 inserts field zero and \n requests a newline. The quoting matters because the display format is one shell argument. A format file supplied with -fs uses one property or type per line. The XPROPFORMATS environment variable can supply another format file, and xprop searches those sources in a defined order. If output is inexplicably different between shells, check that variable before rewriting a working command.

5. Watch a property change

Use -spy when you need to see property-change events continuously:

$ xprop -spy -id 0x200007 WM_NAME
WM_NAME(STRING) = "Example window"
# output continues while the window changes

This is a long-running diagnostic command. Stop it with Ctrl-C; that only ends xprop and does not alter the target window. If nothing appears after the initial value, the selected property may not be changing, or the application may be updating a different property such as _NET_WM_NAME.

6. Treat setters and removals as state changes

Warning: -set changes a property on the target window, and -remove deletes one. They can change application behaviour immediately. Do not use them as harmless display commands, and do not test them against a window you do not own.

For a disposable test window, the manual demonstrates setting a simple string property by declaring an 8-bit string format:

$ xprop -root -f MY_ATOM_NAME 8s -set MY_ATOM_NAME 'my_value'

Read the property back immediately with a format appropriate to the target, and inspect xprop's diagnostics. The property name, existing type and X server implementation all matter; an incompatible conversion can be rejected rather than creating the value you intended. A successful command is not a substitute for a readback check.

If the property was created or changed, the corresponding undo operation is:

$ xprop -root -remove MY_ATOM_NAME

Use a unique test property name. Never overwrite a property used by a window manager or application unless you have documented the original value and a recovery plan. The command does not require sudo; elevated privileges do not make an unsafe X property edit safe.

Diagnose the usual failures

Done means