4

I want to know the process ID of a particular window. I have seen and used the Force close panel applet, and I'd like something similar that would report me the process ID of the window I select.

If a tool for this purpose exists, that'd be great. Although, I am willing even to write a simple python script if it can be done.

Edit: In a more specific case, I want to get the process ID of a java swing window. (The xprop solution some answers suggest is not working).

Thanks.

sharat87
  • 353

3 Answers3

2

Use xprop _NET_WM_PID and click the window you want to query.

For instance, if you run it on a gnome-terminal:

 $ xprop _NET_WM_PID
 _NET_WM_PID(CARDINAL) = 2386
 $ pidof gnome-terminal
 2386
Egil
  • 14,162
  • Thanks Egil, this seems to work for few windows, but I am trying on a java swing window, and the output comes as _NET_WM_PID: not found. Any idea? – sharat87 Apr 21 '11 at 10:54
1
xprop _NET_WM_PID | cut -d' ' -f3

That will give you a target, click a window and it'll give you the PID.

I'm sending the output through cut (you could use awk '{ print $3 }' instead if you like) to clean it up so you could script it into something else, if you needed to.

Oli
  • 293,335
  • Please see my comment on Egil's answer, this does not work for java swing windows. Any other way to do this? – sharat87 Apr 21 '11 at 10:55
0

You could also open System Monitor. Switch to the Processes tab and look for your Java window.

Jeremy Bicha
  • 8,234
  • All my java processes are listed as, well, java in that tab. How to know which process has opened which window? I couldn't find anything that shows this. – sharat87 May 03 '11 at 06:27