Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux: how to get a list of all visible windows

Tags:

java

linux

gnome

Disclaimer: I know there is a very similar question on this topic.

I am trying to get exactly the same result that NoozNooz42 described here. However mdma answer doesn't fit my needs, because I'm interested in doing the same on linux. Preferrably with gnome, if it matters. So using JNA with user32 library is not a option here (or is it?).

Any suggestions will be great, I couldn't find almost anything on the topic.

P.S. The only thing I have found is wmctrl command (I could call and parse it in java eventually) that lists windows but doesn't give me any information about the z-order.

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

like image 705
Adam Pierzchała Avatar asked Mar 26 '13 13:03

Adam Pierzchała


People also ask

How do I see all windows in Linux?

For Linux Mint 18 Sarah ,< ctrl+alt+down-key > worked to display all the open windows in the current desktop. To view all the windows in all the desktops, use < ctrl+ alr+ up-key >.

What is Wmctrl in Linux?

wmctrl is a command used to control windows in EWMH- and NetWM-compatible X Window window managers. Some of its common operations are list, resize, and close window. It also has the ability to interact with virtual desktops and give information about the window manager.


1 Answers

Use xprop, it shows window properties. List of windows in z-order is in property _NET_CLIENT_LIST_STACKING of the root window:

xprop -root | grep '_NET_CLIENT_LIST_STACKING(WINDOW)'

Output should look like this:

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

Later you can get more info about particular windows with:

xprop -id <id>

or

xwininfo -id <id>
like image 106
Jarosław Jaryszew Avatar answered Sep 18 '22 08:09

Jarosław Jaryszew