66

Is there any package which shows PID of a window by clicking on it?

Nick.h
  • 6,193
  • 4
  • 20
  • 16

3 Answers3

88

Yes. Try xprop and you are looking for the value of _NET_WM_PID:

xprop _NET_WM_PID | cut -d' ' -f3
{click on window}
Caleb
  • 69,278
  • 18
  • 196
  • 226
  • 15
    Note that this information is provided voluntarily by the client and need not be correct, present or meaningful (remote clients, clients in a separate PID namespace). – Simon Richter Aug 22 '11 at 13:23
24

xprop will return a window's PID.

You can filter the verbose output using awk:

xprop | awk '/PID/ {print $3}'
jasonwryan
  • 71,734
  • 34
  • 193
  • 226
1

To complete those excellent answers, here is a little bash command to get the command (that I actually needed):

id=`xprop _NET_WM_PID | awk '/PID/ {print $3}'`; cat /proc/$id/comm

Example:

Lila ~ # id=`xprop _NET_WM_PID | awk '/PID/ {print $3}'`; cat /proc/$id/comm

gnome-terminal-

brunetton
  • 253
  • 2
  • 6