How can I kill a specific X window
If you use wmctrl -lp
the PIDs are in the third column.
For a given window ID you can use
kill $(wmctrl -lp | awk '/^WID/ {print $3}')
(replace WID with your window ID)
Besides listing the PID as described in other answers by Florian Diesch and Serg, you can use -ic
option to close the window directly:
$ wmctrl -ic 0x02e00085
wmctrl
actually has another flag -p
for listing PID.
bash-4.3$ wmctrl -lp
0x0380000a 0 4410 eagle Desktop
0x04800006 0 4275 eagle XdndCollectionWindowImp
0x04800009 0 4275 eagle unity-launcher
0x0480000c 0 4275 eagle unity-panel
0x0480000f 0 4275 eagle unity-dash
0x04800010 0 4275 eagle Hud
Once you know this, it's a trivial exercise of extracting that window's PID and passing it to kill
wmctrl -lp | awk '/Window Title/{print $3}' | xargs kill