Get X window id from process in bash

grinchfox Colinsgrove picture grinchfox Colinsgrove · Dec 14, 2013 · Viewed 7.7k times · Source

Is there any bash tool/warper that could tell which x window(s) has been created by specific process ?

Answer

Andrey Sidorov picture Andrey Sidorov · Dec 15, 2013

As mentioned, you can use command line tools like wmctrl or xprop. Well behaved clients should set _NET_WM_PID property to be pid of the process which created main window (all popular toolkits do this for you). Note that some clients don't set it or may be on another physical machine (you can use WM_CLIENT_MACHINE property) - so use this information as a hint and don't rely on it to be present or accurate. See emwh spec at freedesktop for reference.