This question already has an answer here:

I decided to get the completely unused pause key on my keyboard to actually pause things so I wrote a pause <pid> shell function to toggle the state a process and assigned pause $(xdotool getwindowfocus getwindowpid) to the key with sxhkd.

The problem is that xdotool and other utilities I have tried rely on the _NET_WM_PID property which is really unrealiable in my setup: I use firejail for the majority of programs and in that case it seems to always return the PID "3" while for games and other binaries running in a chroot environment the property it's not even set.

Is there any other method to associate a PID to a window? The X.org server must have this information, or does it?

marked as duplicate by Gilles, Kusalananda, Tomasz, thrig, Jeff Schaller Feb 4 '17 at 17:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Curious to "other utilities"; when you run wmctrl -lp, is the window listed correctly? (assuming you have wmctrl installed). – Jacob Vlijm Feb 4 '17 at 6:37
  • Also try xlsclients -a -l instead of wmctrl. – dirkt Feb 4 '17 at 13:51

Browse other questions tagged or ask your own question.