15

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?

  • I doubt that there is or will ever be such a command like xprop. One major goal of Wayland is to restrict access to windows of other processes. – mviereck Feb 18 '18 at 8:38
  • @mviereck Surely the superuser could see window information, even in Wayland? – Nathaniel M. Beaver Feb 20 '18 at 13:12
  • @bariumbitmap: Only if the compositor provides these informations outside of its own memory, for example in a file or through an API. I am not aware of such a specification (but it may exist, though). Of course, you could fork a compositor like weston and implement that yourself, if you don't need a general solution for all compositors. – mviereck Feb 20 '18 at 15:52
  • Why not just xprop? It shows an awful lot of detail over a window via XWayland, including _NET_WM_PID(CARDINAL), which is the originator process PID. – istepaniuk Apr 5 at 15:18
1

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:

alt ft

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:

window section

From there, you'll see a list of windows, from which you can click on the name of the window you want to identify.

list

In this case, I chose gedit for an example:

gedit

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

I've

  • 3
    So does this allow to find out the PID of process running the listed window? – czerny Apr 3 '18 at 22:55
0

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.