Linux: how to get a list of all visible windows

Disclaimer: I know that question is very similar in this thread .

I am trying to get the same result that NoozNooz42 described here . However, the answer of mdma does not meet my needs, because I am interested in doing the same on linux. Preferably with a gnome, if that matters. So using JNA with the user32 library is not an option here (or is it?).

Any suggestions would be great, I could not find anything about this.

PS The only thing I found was the wmctrl command (I can call and parse it in java), which displays windows but does not give me any information about the z-order.

Update: It would be ideal if I could get a notification / callback when the z-order changes.

+5
source share
1 answer

Use xprop, it shows window properties. The list of windows in z-order is in the property of the _NET_CLIENT_LIST_STACKINGroot window:

xprop -root | grep '_NET_CLIENT_LIST_STACKING(WINDOW)'

The result should look like this:

_NET_CLIENT_LIST_STACKING(WINDOW): window id # 0x2000003, 0x4000004,
0x1c00004, 0x1c00030, 0x1c00033, 0x2e00004

Later you can get additional information about specific windows with:

xprop -id <id>

or

xwininfo -id <id>
+6
source

All Articles