Let us start by defining what is xprop
. xprop
is simply a tool, to query, set, and remove the properties of an X11
window .
Additionally, using xprop
, you can query X11
core fonts attributes, so you can get the values, of the logical font name description, and additional attributes, such as the X_HEIGHT
, and the CAP_HEIGHT
.
Table of Contents
Window properties
Selecting a window
Before being able to do anything, with xprop
, you need to select, the window, that you are interested in.
This can be done, by using one of the four methods:
-
xprop -root
: Select the screen root window. -
xprop
: Execute thexprop
command, and click on a window, to select it. -
xprop -id window_id
: Select a window, by specifying its id. -
xprop -name window_name
: Select a window, by specifying its name.
The first two methods, are self explanatory, concerning the last two, the question to ask, is how to get the id, or the name, of a window.
The answer, is that you can use the command, xwininfo -root -tree
, to list the ids, and the names, for all the windows, starting from the root window.
$ xwininfo -root -tree # As the output shows, the # root window, has an id of # 0xac , in hexadecimal, and # it has no name. # The root window, has one child, # which has an id of 0x600000, # followed by its name of # xwinclip. xwininfo: Window id: 0xac (the root window) (has no name) Root window id: 0xac (the root window) (has no name) Parent window id: 0x0 (none) 1 child: 0x600000 "xwinclip": () 500x500+1+1 +1+1
The previous command, listed the window id in hexadecimal, if you are more interested, in getting the window id in decimal, then you can use xwininfo -root -tree -int
.
$ xwininfo -root -tree -int # List all the windows, ids and names # starting from the root window. The # id is displayed in decimal. xwininfo: Window id: 172 (the root window) (has no name) Root window id: 172 (the root window) (has no name) Parent window id: 0 (none) 1 child: 6291456 "xwinclip": () 500x500+1+1 +1+1
Displaying a window properties
To list a window properties, and display their information, any of the window selection methods, described in the previous section, can be used.
A window property, is a way to exchange information. It has a name, a type, and a value …
Some properties are set by the window manager, other properties, are set by other X11
clients.
Displaying the properties of the root window
In this first example, the properties of the root window, are being printed.
$ xprop -root # Show all the properties, associated # with the screen root window. # The property name, is first displayed, # followed by its type in parenthesis, # followed by the value stored in this # property. # Output: _NET_NUMBER_OF_DESKTOPS(CARDINAL) = 1 # The property contains as a value, # the number of virtual desktops. # This property is set by the window # manager __NET_DESKTOP_NAMES(UTF8_STRING) = "Desktop" # The property is of type UTF8_STRING, # its value, is the names, of the # virtual desktops. _NET_CURRENT_DESKTOP(CARDINAL) = 0 # Index of the current desktop _NET_SUPPORTED(ATOM) = WM_PROTOCOLS, _NET_SUPPORTED, _NET_SUPPORTING_WM_CHECK, _NET_CLOSE_WINDOW, _NET_WM_WINDOW_TYPE, _NET_WM_WINDOW_TYPE_DOCK, _NET_WM_WINDOW_TYPE_SPLASH, _NET_WM_STATE, _NET_WM_STATE_HIDDEN, _NET_WM_STATE_ABOVE, _NET_WM_STATE_BELOW, _NET_WM_STATE_SKIP_TASKBAR, _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_HORZ # Hints supported by the window manager
Displaying the properties of any window
In this second example, the properties of a window, are being displayed, by specifying the window id. The same result, is obtained, if the window name, has been specified , or if the xprop
command is executed, and using the mouse, the window you are interested in getting its properties, is clicked.
$ xwininfo -root -tree | grep xclock # Using xwininfo, list all the # windows, and using grep, # find the window named xclock, # in order to find out, its id, # and name. 0x80000a "xclock": ("xclock" "XClock") 164x164+190+213 +190+213 $ xprop -id 0x80000a # List the properties, related # to the window, with an id # of 0x80000a, in hexadecimal. # This will print the property name, # followed by its type, followed by # its value. # Output: WM_STATE(WM_STATE): window state: Normal icon window: 0x0 # The property is set by # the window manager, and # is the state of the window. WM_CLIENT_MACHINE(STRING) = "DSKTP-TOAPK1I" # The property is set by the # client, and is the host name # of the machine, where the # client is running. _NET_WM_PID(CARDINAL) = 6572 # The property contains, the # process id, of the client, # which owns the window. WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW # WM_PROTOCOLS is a property, containing # which protocol messages, the client # wishes to receive. # WM_DELETE_WINDOW means, that if # a window is going to be deleted, # like for example, the user closing # the window, the client is notified, # and it can for example, ask the user # for confirmation. WM_CLASS(STRING) = "xclock", "XClock" # WM_CLASS property, is of type # string, it contains the instance # and the class name of an application. # In this case, instance is xclock, # and class is XClock. # The instance and class name, # can be used to find, or specify # resources, related to an application. # If a resource is specified by class name, # it applies to all applications, with that # class name. # An application instance name, can # possibly be specified, using the -name # option, when launching an application. # The application class name, is specified, # by the person, who wrote the application. WM_NORMAL_HINTS(WM_SIZE_HINTS): program specified size: 164 by 164 window gravity: NorthWest # This property, is set by the # client, and is read by the window # manager. The client can use this # property, to inform the window # manager, of its preferred width # and height. WM_HINTS(WM_HINTS): Client accepts input or input focus: False Initial state is Normal State. bitmap id # to use for icon: 0x800001 bitmap id # of mask for icon: 0x800003 # This property is set by the client, # it informs the window manager, # of certain things, such as the # bitmap to be used as an icon. WM_COMMAND(STRING) = { "xclock" } # This property is of type string, # it contains the command, which # started the application. WM_NAME(STRING) = "xclock" # This property is set by the # client, it is of type string, # and the window manager, can use # it, to display a title, for # the window. WM_LOCALE_NAME(STRING) = "en_US.UTF-8" # Property detailing, the name # of the current locale. $ xprop -name xclock # You can also use this # command, to get the same # result shown, as in the # previous command. In this # case, you are using the # name of the window, you are # interested in, instead of # its id. $ xwininfo -root -tree -int | grep xclock # Grep a window which name # contains the term xclock, # and we want the id to be # displayed, in decimal . 8388618 "xclock": ("xclock" "XClock") 164x164+190+213 +190+213 $ xprop -id 8388618 # Display the list of properties, # associated with the xclock # window, by specifying its # id in decimal. # The result is as the one # using: # xprop -id 0x80000a # which is specifying the # id, in hexadecimal.
Displaying a specific property
Additionally, if you are just interested, in viewing, information about a specific property, associated with a window, you just have to specify, the name of that property, on the command line.
$ xprop WM_NAME -name xclock # Display information, about the # property named WM_NAME, # associated with the xclock # window. WM_NAME(STRING) = "xclock" $ xprop WM_NAME WM_CLASS -name xclock # Display information, about both # the properties, WM_NAME, and # WM_CLASS, associated with the # window, named xclock . WM_NAME(STRING) = "xclock" WM_CLASS(STRING) = "xclock", "XClock"
Limit the number of value bytes, displayed
You can limit the number of bytes, to be displayed, for the values stored in properties, by using the -len length
option.
$ xprop -len 5 -name xclock # Only display the first 5 bytes, # for each property value, for the # propeties of the window named # xclock. WM_STATE(WM_STATE): window state: Normal icon window: <field not available> _NET_WM_PID(CARDINAL) = 6572 WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW WM_LOCALE_NAME(STRING) = "en_US" WM_CLASS(STRING) = "xcloc" WM_HINTS(WM_HINTS): Client accepts input or input focus: <field not available> Initial state is . bitmap id # to use for icon: <field not available> bitmap id # of mask for icon: <field not available> WM_NORMAL_HINTS(WM_SIZE_HINTS): program specified size: <field not available> by <field not available> window gravity: WM_CLIENT_MACHINE(STRING) = "DSKTP" WM_COMMAND(STRING) = { "xcloc" } WM_ICON_NAME(STRING) = "xcloc" WM_NAME(STRING) = "xcloc" $ xprop -len 2 WM_NAME -name xclock # Display only the first two bytes, # of the value, of the property named # WM_NAME, attached to the window # named xclock. WM_NAME(STRING) = "xc"
Do not display the type
If you are not interested in displaying the type of properties , you can use the -notype
option, as follows:
$ xprop -notype -name xclock # List the properties of the # xclock window , but without # displaying the properties # types. WM_STATE: window state: Normal icon window: 0x0 _NET_WM_PID = 6572 WM_PROTOCOLS: protocols WM_DELETE_WINDOW _WINDOWSWM_NATIVE_HWND = 9701962, 0 WM_CLIENT_LEADER: window id # 0x80000a WM_LOCALE_NAME = "en_US.UTF-8" WM_CLASS = "xclock", "XClock" WM_HINTS: Client accepts input or input focus: False Initial state is Normal State. bitmap id # to use for icon: 0x800001 bitmap id # of mask for icon: 0x800003 WM_NORMAL_HINTS: program specified size: 164 by 164 window gravity: NorthWest WM_CLIENT_MACHINE = "DESKTOP-LEUTR3F" WM_COMMAND = { "xclock" } WM_ICON_NAME = "xclock" WM_NAME = "xclock" $ xprop -notype WM_NAME -name xclock # Display only the name, and the # value of the property named # WM_NAME, attached to the xclock # window. WM_NAME = "xclock"
Custom output formatting
If you want to provide custom formatting, and only display certain properties, it can be done like so:
$ xprop 0sx ':\n\t Instance Name $0 \n\t Class name : $1 \n' WM_CLASS -name xclock WM_CLASS(STRING): Instance Name "xclock" Class name : 0x58 # 0 is the property format, # it can be 8, 16, or 32. # 0 can be used to let the # property format, be gotten # from the property itself. # s and x is how the data is # going to be displayed. Other # specifiers, can also be used. # s stands, for display data, as # a c string. # a stands for display data, as an # atom. An atom is 32 bits. # b for boolean. A 0 value is displayed # as false, anything else as true. # c for cardinal, which is display data # as an unsigned number. # i for integer, data is displayed as # an integer. # o for data being displayed, as an array # consisting of 32 bit values, # the width, height, and ARGB of # icons . # u for data being displayed, as being # encoded, as a utf-8 string. # t , for string being converted, to # current locale encoding, before # being output. # x for data being displayed, as a # hex number. # $0, $1 ... can be used to address # individual fields, of the # property values. # \n will cause a new line, and \t # will print a tab. $ xprop 0bi ':\n\t Instance Name $0 \n\t Class name : $1 \n' WM_CLASS 0s ' is : $0 \n' WM_LOCALE_NAME -name xclock # In this example, custom formatting is # done, for both WM_CLASS, and # WM_LOCALE_NAME . WM_CLASS(STRING): Instance Name True Class name : 99 WM_LOCALE_NAME(STRING) is : "en_US.UTF-8"
You can also display all the properties, and do custom formatting, for only some specific properties, as follows:
$ xprop -f WM_CLASS 0bi ':\n\t Instance Name $0 \n\t Class name : $1 \n' -f WM_LOCALE_NAME 0s ' is : $0 \n' -name xclock # Using the -f option, specify # the name of the property, you # wish to format, the property # format and type, and how it is # going to be displayed. WM_STATE(WM_STATE): window state: Normal icon window: 0x0 _NET_WM_PID(CARDINAL) = 6572 WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW WM_LOCALE_NAME(STRING) is : "en_US.UTF-8" WM_CLASS(STRING): Instance Name True Class name : 99 WM_HINTS(WM_HINTS): Client accepts input or input focus: False Initial state is Normal State. bitmap id # to use for icon: 0x800001 bitmap id # of mask for icon: 0x800003 WM_NORMAL_HINTS(WM_SIZE_HINTS): program specified size: 164 by 164 window gravity: NorthWest WM_CLIENT_MACHINE(STRING) = "DSKTP-TOAPK1I" WM_COMMAND(STRING) = { "xclock" } WM_ICON_NAME(STRING) = "xclock" WM_NAME(STRING) = "xclock"
Finally, instead of using the -f
option, you can use the -fs filename
option, to specify a file, used for custom formatting.
$ cat format.fs # An example of the output # of a file, containing custom # formatting, for two properties. WM_CLASS 0bi ':\n\t Instance Name $0 \n\t Class name : $1 \n' WM_LOCALE_NAME 0s ' is : $0 \n' $ xprop.exe -fs tmp.fs -name xclock # Instead of using the -f # option, the -fs option # is used. WM_STATE(WM_STATE): window state: Normal icon window: 0x0 _NET_WM_PID(CARDINAL) = 6572 WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW WM_LOCALE_NAME(STRING) is : "en_US.UTF-8" WM_CLASS(STRING): Instance Name True Class name : 99 WM_HINTS(WM_HINTS): Client accepts input or input focus: False Initial state is Normal State. bitmap id # to use for icon: 0x800001 bitmap id # of mask for icon: 0x800003 WM_NORMAL_HINTS(WM_SIZE_HINTS): program specified size: 164 by 164 window gravity: NorthWest WM_CLIENT_MACHINE(STRING) = "DSKTP-TOAPK1I" WM_COMMAND(STRING) = { "xclock" } WM_ICON_NAME(STRING) = "xclock" WM_NAME(STRING) = "xclock"
Continuously monitoring a window
If you are interested, in continuously monitoring a window, for any change in its properties, you can use the -spy
option.
$ xprop -spy -name xclock # Monitor the xclock window, # for any change, in its properties. WM_STATE(WM_STATE): window state: Normal icon window: 0x0 WM_CLIENT_MACHINE(STRING) = "DSKTP-TOAPK1I" _NET_WM_PID(CARDINAL) = 6572 WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW WM_CLASS(STRING) = "xclock", "XClock" WM_NORMAL_HINTS(WM_SIZE_HINTS): program specified size: 164 by 164 window gravity: NorthWest WM_HINTS(WM_HINTS): Client accepts input or input focus: False Initial state is Normal State. bitmap id # to use for icon: 0x800001 bitmap id # of mask for icon: 0x800003 WM_COMMAND(STRING) = { "xclock" } WM_NAME(STRING) = "xclock" WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
Adding a property to a window
To add a property to a window, it can be done like this:
$ xcalc & # Launch the xcalc application $ xwininfo -root -tree | grep xcalc # Find the id, and name of # a window, containing the # term xcalc . 0x800011 "Calculator": ("xcalc" "XCalc") 226x394+138+161 +138+161 $ xprop -name Calculator -format WM_NAME 8s -set WM_NAME Calc # set or update a property # on a window named # Calculator. # The name of the window is first # specified using: # -name Calculator # The -format option, is followed # by the property name, and its # format and type. # The format can be 8, for 8 # bits, 16, for 16 bits, and # 32, for 32 bits. # The type can be for example, # s for a c string, c for # cardinal, i for # an integer .. # The -set option is used, # to set the value for the # property. So in this case, # the property type is a C # string, so the value is # considered a C string. $ xprop -name Calc -format MY_PROP_1 32i -set MY_PROP_1 898 # In the previous example, the # window name of Calculator, # was changed to Calc. This is # why, in this example the # -name Calc option is used. # This example defines a new # property, it has a format of # 32 bits, and is of the integer # type, and its value is set # to 898. $ xprop MY_PROP_1 -name Calc # Display information, about # the property named MY_PROP_1, # associated with the window # having the name of Calc . MY_PROP_1(INTEGER) = 898
Removing a property from a window
To remove a property, from a window, you can use the -remove property_name
option, as follows:
$ xcalc & # Launch the xcalc application. $ xwininfo -root -tree | grep xcalc # Find the id, and the name of a # window containing the term # xcalc. 0x800011 "Calculator": ("xcalc" "XCalc") 226x394+112+135 +112+135 $ xprop WM_NAME -name Calculator # Show the details of a property, # named WM_NAME, associated with # the window named, Calculator. WM_NAME(STRING) = "Calculator" $ xprop -remove WM_NAME -name Calculator # Remove the property named # WM_NAME, associated with # the window which has name of # Calculator. $ xprop -name Calculator # After removing the WM_NAME # property, it is not possible # to refer to the window, using # its name. xprop: error: No window with name Calculator exists! $ xprop WM_CLASS -id 0x800011 # But it is still possible, # to refer, to the window, by using # its id. WM_CLASS(STRING) = "xcalc", "XCalc"
Showing fonts attributes
On one hand, The X11
core fonts , which are installed on a system, can have their name listed, by using the xlsfonts
command.
$ xlsonts # List the names of the core # fonts, installed on the # system. -adobe-courier-bold-o-normal--10-100-75-75-m-60-iso10646-1 -adobe-courier-bold-o-normal--10-100-75-75-m-60-iso8859-1 -adobe-courier-bold-o-normal--10-100-75-75-m-60-iso8859-10 -adobe-courier-bold-o-normal--10-100-75-75-m-60-iso8859-13 -adobe-courier-bold-o-normal--10-100-75-75-m-60-iso8859-14 -adobe-courier-bold-o-normal--10-100-75-75-m-60-iso8859-15 ...
On the other hand, If one is interested, in getting detailed information, about an X11
core font, then xprop -font font_name_wildcards
, can be used. Using wildcards, in an X11
core font name, is described in more details here .
xprop -font '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-10' # Displaying detailed information # about the font named # '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-10' FOUNDRY = Adobe FAMILY_NAME = Courier WEIGHT_NAME = Bold SLANT = O SETWIDTH_NAME = Normal ADD_STYLE_NAME = PIXEL_SIZE = 12 POINT_SIZE = 120 RESOLUTION_X = 75 RESOLUTION_Y = 75 SPACING = M AVERAGE_WIDTH = 70 CHARSET_REGISTRY = ISO8859 CHARSET_ENCODING = 10 CAP_HEIGHT = 8 X_HEIGHT = 6 FACE_NAME = Courier Bold Oblique COPYRIGHT = Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved. NOTICE = No mark _DEC_DEVICE_FONTNAMES = 0x153 RELATIVE_SETWIDTH = 50 RELATIVE_WEIGHT = 70 FULL_NAME = 0x14f FONT = -Adobe-Courier-Bold-O-Normal--12-120-75-75-M-70-ISO8859-10 WEIGHT = 10 RESOLUTION = 103 QUAD_WIDTH = 7 $ xprop -font '-adobe-*--12-120-75-75-?-70-iso8859-10' # Display detailed information, # about a font name, which is # specified by using wildcards, # * matches more than one character # ? matches a single character. # The first font found, in the path # satisfying the criteria, has its # information displayed. FOUNDRY = Adobe FAMILY_NAME = Courier WEIGHT_NAME = Bold SLANT = O SETWIDTH_NAME = Normal ADD_STYLE_NAME = PIXEL_SIZE = 12 POINT_SIZE = 120 RESOLUTION_X = 75 RESOLUTION_Y = 75 SPACING = M AVERAGE_WIDTH = 70 CHARSET_REGISTRY = ISO8859 CHARSET_ENCODING = 10 CAP_HEIGHT = 8 X_HEIGHT = 6 FACE_NAME = Courier Bold Oblique COPYRIGHT = Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved. NOTICE = No mark _DEC_DEVICE_FONTNAMES = 0x153 RELATIVE_SETWIDTH = 50 RELATIVE_WEIGHT = 70 FULL_NAME = 0x14f FONT = -Adobe-Courier-Bold-O-Normal--12-120-75-75-M-70-ISO8859-10 WEIGHT = 10 RESOLUTION = 103 QUAD_WIDTH = 7
Specifying the connection to use
To specify the connection string, to use, this can be done by using the -display display
option. If this option is not used, then the environment variable DISPLAY
, is used to indicate, the connection string.
$ echo $DISPLAY # Print the value, of the # environment variable DISPLAY, # which contains the connection # string. :0 $ xprop WM_CLASS -name xclock -display :0 # The connection string is set to :0, # the property to print its information # is WM_CLASS, and the name of the window # to which the property is attached, is # xclock. WM_CLASS(STRING) = "xclock", "XClock"