I'd like to identify which process a window belongs to in Wayland. Is there anything like
xprop for X that allows the user to pick a window by clicking and outputs all window details, including PID?
Good news, there IS something like this built into Gnome Shell, and unlike
xprop works with Xorg and Wayland. Ultimately this may fall into the realm of other tooling if you're using KDE, i3, or something else.
To begin with, type the keys "ALT+F2" on the keyboard which will bring up a menu like this:
After that comes up, issue the command
lg (for "looking glass).
This will then bring up the looking glass window, from which we can extract window information. Select "window" from the top right corner of the looking glass:
From there, you'll see a list of windows, from which you can click on the name of the window you want to identify.
In this case, I chose gedit for an example:
In the top line of that output you may notice:
Inspecting object: object instance proxy GType: MetaWindowX11 ...`
The "GType" will be one of MetaWindowX11 or MetaWindowWayland.
This info comes as per https://fedoraproject.org/wiki/How_to_debug_Wayland_problems
There is a draft of
xdg-foreign protocol extension, which allows obtaining handles of
wl_surface's, created by other Wayland clients. Having the handle, you can obtain from it anything you can obtain from surfaces of your client. However, this protocol still has limitations:
- Obviously, it won't work if not implemented in clients.
- It's targeted for clients that know each other, so it does not provide a way to trigger it: your client communicates with a foreign client in some way, not covered by the extension. Then the foreign client publishes a handle for your client via this extension.
- It gains too much control, if compared to
xprop. Actually, you can even draw on foreign surfaces!
So, this is unlikely to become a general way to get surface parameters from any client by any client. But don't lose a hope: there are a lot of examples in tech history when a technology, initially designed for some purpose, became widely used for other purposes, just like car cigarette lighters or Accessibility APIs in Android. Moreover, in the future, there may appear a protocol extension that is more suited for your task, as there is definitely a need for it (for example, for time trackers).