The xprop utility is for displaying window and font properties in an X server. One window or font is selected using the command line arguments or possibly in the case of a window, by clicking on the desired window. A list of properties is then given, possibly with formatting information.
For each of these properties, its value on the selected window or font is printed using the supplied formatting information if any. If no formatting information is supplied, internal defaults are used. If a property is not defined on the selected window or font, "not defined" is printed as the value for that property. If no property list is given, all the properties possessed by the selected window or font are printed.
A window may be selected in one of four ways. First, if the desired window is the root window, the -root argument may be used. If the desired window is not the root window, it may be selected in two ways on the command line, either by id number such as might be obtained from _x_w_i_n_i_n_f_o, or by name if the window possesses a name. The -id argument selects a window by id number in either decimal or hex (must start with 0x) while the -name argument selects a window by name.
The last way to select a window does not involve the command line at all. If none of -font, -id, -name, and -root are specified, a crosshairs cursor is displayed and the user is allowed to choose any visible window by pressing any pointer button in the desired window. If it is desired to display properties of a font as opposed to a window, the -font argument must be used.
Other than the above four arguments and the -help argument for obtaining help, and the -grammar argument for listing the full grammar for the command line, all the other command line arguments are used in specifying both the format of the properties to be displayed and how to display them. The -len _n argument specifies that at most _n bytes of any given property will be read and displayed. This is useful for example when displaying the cut buffer on the root window which could run to several pages if displayed in full.
Normally each property name is displayed by printing first the property name then its type (if it has one) in parentheses followed by its value. The -notype argument specifies that property types should not be displayed. The -fs argument is used to specify a file containing a list of formats for properties while the -f argument is used to specify the format for one property.
The formatting information for a property actually consists of two parts, a _f_o_r_m_a_t and a _d_f_o_r_m_a_t. The _f_o_r_m_a_t specifies the actual formatting of the property (i.e., is it made up of words, bytes, or longs?, etc.) while the _d_f_o_r_m_a_t specifies how the property should be displayed.
The following paragraphs describe how to construct _f_o_r_m_a_ts and _d_f_o_r_m_a_ts. However, for the vast majority of users and uses, this should not be necessary as the built in defaults contain the _f_o_r_m_a_ts and _d_f_o_r_m_a_ts necessary to display all the standard properties. It should only be necessary to specify _f_o_r_m_a_ts and _d_f_o_r_m_a_ts if a new property is being dealt with or the user dislikes the standard display format. New users especially are encouraged to skip this part.
A _f_o_r_m_a_t consists of one of 0, 8, 16, or 32 followed by a sequence of one or more format characters. The 0, 8, 16, or 32 specifies how many bits per field there are in the property. Zero is a special case meaning use the field size information associated with the property itself. (This is only needed for special cases like type INTEGER which is actually three different types depending on the size of the fields of the property.)
A value of 8 means that the property is a sequence of bytes while a value of 16 would mean that the property is a sequence of words. The difference between these two lies in the fact that the sequence of words will be byte swapped while the sequence of bytes will not be when read by a machine of the opposite byte order of the machine that originally wrote the property. For more information on how properties are formatted and stored, consult the Xlib manual.
Once the size of the fields has been specified, it is necessary to specify the type of each field (i.e., is it an integer, a string, an atom, or what?) This is done using one format character per field. If there are more fields in the property than format characters supplied, the last character will be repeated as many times as necessary for the extra fields. The format characters and their meaning are as follows:
An example _f_o_r_m_a_t is 32ica which is the format for a property of three fields of 32 bits each, the first holding a signed integer, the second an unsigned integer, and the third an atom.
The format of a _d_f_o_r_m_a_t unlike that of a _f_o_r_m_a_t is not so rigid. The only limitations on a _d_f_o_r_m_a_t is that one may not start with a letter or a dash. This is so that it can be distinguished from a property name or an argument. A _d_f_o_r_m_a_t is a text string containing special characters instructing that various fields be printed at various points in a manner similar to the formatting string used by printf. For example, the _d_f_o_r_m_a_t " is ( $0, $1 \)\n" would render the POINT 3, -4 which has a _f_o_r_m_a_t of 32ii as " is ( 3, -4 )\n".
Any character other than a $, ?, \, or a ( in a _d_f_o_r_m_a_t prints as itself. To print out one of $, ?, \, or ( precede it by a \. For example, to print out a $, use \$. Several special backslash sequences are provided as shortcuts. \n will cause a newline to be displayed while \t will cause a tab to be displayed. \_o where _o is an octal number will display character number _o.
A $ followed by a number _n causes field number _n to be displayed. The format of the displayed field depends on the formatting character used to describe it in the corresponding _f_o_r_m_a_t. I.e., if a cardinal is described by 'c' it will print in decimal while if it is described by a 'x' it is displayed in hex.
If the field is not present in
the property (this is possible with some properties),
A ? is used to start a conditional expression, a kind of if-then statement.
?_e_x_p(_t_e_x_t) will display _t_e_x_t if and only if _e_x_p evaluates to
non-zero. This is useful for two things. First, it allows fields to be
displayed if and only if a flag is set.
And second, it allows a value such as a state
number to be displayed as a name rather than as just a number. The syntax of
_e_x_p is as follows:
The ! operator is a logical ``not'', changing 0 to 1 and any non-zero value to 0.
= is an equality operator. Note that internally all expressions are evaluated
as 32 bit numbers so -1 is not equal to 65535. = returns 1 if the two values
are equal and 0 if not.
_n represents the constant value _n while $_n represents the
value of field number _n.
m_n is 1 if flag number _n in the first field having format
character 'm' in the corresponding _f_o_r_m_a_t is 1, 0 otherwise.
Examples: ?m3(count: $3\n) displays field 3 with a label of count if and only if flag
number 3 (count starts at 0!) is on. ?$2=0(True)?!$2=0(False) displays the
inverted value of field 2 as a boolean.
In order to display a property, _x_p_r_o_p needs both a _f_o_r_m_a_t and a
_d_f_o_r_m_a_t. Before _x_p_r_o_p uses its default values of a _f_o_r_m_a_t
of 32x and a _d_f_o_r_m_a_t of " = { $0+ }\n", it searches several places
in an attempt to find more specific formats.
First, a search is made using the name of the property. If this
fails, a search is made using the type of the property. This allows type
STRING to be defined with one set of formats while allowing property WM_NAME
which is of type STRING to be defined with a different format. In this way,
the display formats for a given type can be overridden for specific properties.
The locations searched are in order: the format if any specified with the
property name (as in 8x WM_NAME), the formats defined by -f options in last to
first order, the contents of the file specified by the -fs option if any,
the contents of the file specified by the environmental variable XPROPFORMATS
if any, and finally _x_p_r_o_p's built in file of formats.
The format of the files referred to by the -fs argument and the XPROPFORMATS
variable is one or more lines of the following form:
_n_a_m_e _f_o_r_m_a_t [_d_f_o_r_m_a_t]
Where _n_a_m_e is either the name of a property or the name of a type,
_f_o_r_m_a_t is the _f_o_r_m_a_t to be used with _n_a_m_e and _d_f_o_r_m_a_t
is the _d_f_o_r_m_a_t to be used with _n_a_m_e. If _d_f_o_r_m_a_t is not
present, " = $0+\n" is assumed.
To display the name of the root window: _x_p_r_o_p -root WM_NAME
To display the window manager hints for the clock: _x_p_r_o_p -name xclock
WM_HINTS
To display the start of the cut buffer: _x_p_r_o_p -root -len 100 CUT_BUFFER0
To display the point size of the fixed font: _x_p_r_o_p -font fixed POINT_SIZE
To display all the properties of window # 0x200007: _x_p_r_o_p -id 0x200007
EXAMPLES
ENVIRONMENT
SEE ALSO
X(7), xdpyinfo(1), xwininfo(1),
xdriinfo(1), glxinfo(1), xvinfo(1)
AUTHOR
Mark Lillibridge, MIT Project Athena