Which app owns a particular X window? (Shallow Thoughts)

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Wed, 15 Apr 2009

Which app owns a particular X window?

Someone on a mailing list was trying to figure out what app brought up a particular Gnome window, so she could run it on a machine that didn't have the Gnome desktop menus or panel.

Sounded like an interesting puzzle. I found a couple of ways, neither of them totally reliable. They both use xprop.

A lot of apps set something called WM_COMMAND to the original command that was run. So

xprop | grep COMMAND
and then click on the window you're interested in, and it gives you something ugly like
WM_COMMAND(STRING) = { "xterm", "-geometry", "80x69+0+0" }

That doesn't seem to work for more modern apps (at least, xchat and firefox don't set WM_COMMAND) so for those, try this:

xprop | grep PID

For apps that support NET_WM_PID, that gives you the process id, e.g.

_NET_WM_PID(CARDINAL) = 4095
and then you can
ps aux | grep 4095

Neither method is perfect, and there are a few apps that won't respond to either one. But most will yield to at least one of these approaches.

Tags:
[ 15:32 Apr 15, 2009    More linux | permalink to this entry | ]

Comments via Disqus:

blog comments powered by Disqus