How to get xid from pid (and vice versa)?

How to get pid from xid (window id x)? How to get a list of xids for a given pid?

(Assume that all applications work with DISPLAY=:0 , without using network transparency)

I expect something like:

  • Insert / proc / $ pid / fd / monitor connection to server X
  • Follow this connection, dig up /proc/`pidof X`/fd
  • Workaround inside X as it needs to know how to map connections to them in windows.
+4
source share
2 answers

You can use xprop -id <windowid> _NET_WM_PID to get the PID property of the corresponding window. You must know the window's window identifier, and not all applications set the _NET_WM_PID atom.

+4
source

This works for my purposes:

 =^_^= izkata@Izein :~$ XID=0x340001c =^_^= izkata@Izein :~$ printf "%d\n" $XID # Convert from hex to decimal 54525980 =^_^= izkata@Izein :~$ xdotool getwindowpid 54526066 20639 =^_^= izkata@Izein :~$ ps 20639 PID TTY STAT TIME COMMAND 20639 ? Ssl 116:25 /usr/lib/firefox/firefox 
+1
source

Source: https://habr.com/ru/post/1346596/


All Articles