How to use the command 'xprop' (with examples)

How to use the command 'xprop' (with examples)

The ‘xprop’ command is a tool for displaying window and font properties in an X server. It provides a way to query various information about windows and fonts, such as the name of the root window, window manager hints, point size of a font, and all the properties of a specific window.

Use case 1: Display the name of the root window

Code:

xprop -root WM_NAME

Motivation: This use case is helpful when you want to identify the name of the root window in your X server. The root window is the top-level window that is created by the X server and serves as the parent window for all other windows.

Explanation:

  • ‘-root’ is an argument that specifies to target the root window of the X server.
  • ‘WM_NAME’ is a property that represents the name of the window manager.

Example output:

WM_NAME(STRING) = "root_window_name"

Use case 2: Display the window manager hints for a window

Code:

xprop -name "window_name" WM_HINTS

Motivation: This use case is useful when you want to retrieve the window manager hints for a specific window. Window manager hints provide information to the window manager about how a window should be handled, such as its initial state (minimized, maximized, etc.) and whether it should be decorated with a titlebar or border.

Explanation:

  • ‘-name “window_name”’ is an argument that specifies the name of the window to target.
  • ‘WM_HINTS’ is a property that represents the window manager hints.

Example output:

WM_HINTS(WM_HINTS):
	hint.flags: State, Icons, InputHint
	hint.initial_state: Normal
	hint.input: False
	...

Use case 3: Display the point size of a font

Code:

xprop -font "font_name" POINT_SIZE

Motivation: This use case is handy if you need to determine the point size of a font. The point size of a font corresponds to its size in points, where 1 point is equivalent to 1/72 inch.

Explanation:

  • ‘-font “font_name”’ is an argument that specifies the name of the font (or font pattern) to target.
  • ‘POINT_SIZE’ is a property that represents the point size of the font.

Example output:

POINT_SIZE(FLOAT) = 12

Use case 4: Display all the properties of the window with the id 0x200007

Code:

xprop -id 0x200007

Motivation: This use case is valuable when you want to retrieve all the properties of a specific window. It provides detailed information about the window, including its dimensions, position, properties, class, and more.

Explanation:

  • ‘-id 0x200007’ is an argument that specifies the ID of the window to target. The ID is represented as a hexadecimal value.

Example output:

_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 58720584
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x2a00011
WM_STATE(WM_STATE):
		window state: Normal
		icon window: 0x0
...

Conclusion:

The ‘xprop’ command is a powerful tool for querying and displaying various properties of windows and fonts in an X server. It allows you to retrieve information about the root window, window manager hints, font point sizes, and more. By understanding the different use cases and their corresponding arguments, you can effectively utilize ‘xprop’ to gather valuable information about the graphical environment in your X server.

Related Posts

Deleting Squashed Branches in Git (with examples)

Deleting Squashed Branches in Git (with examples)

Use Case 1: Deleting squash-merged branches in the current checked out branch Code git delete-squashed-branches Motivation The motivation for using this command is to clean up the local repository by deleting branches that have been squash-merged into the current checked out branch.

Read More
How to use the command 'lumen' (with examples)

How to use the command 'lumen' (with examples)

The ’lumen’ command is a command-line installer for the Lumen micro-framework, which is a lightweight version of the Laravel framework.

Read More
How to use the command git setup (with examples)

How to use the command git setup (with examples)

The command git setup is part of the Git Extras project and is used to create a new Git repository in a specific directory and commit all files.

Read More