-
-
Save diresi/99d72c7533034b22c71647c6e8935a42 to your computer and use it in GitHub Desktop.
xpid: show pid of program that created an X11 window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://www.linuxquestions.org/questions/linux-software-2/something-like-xkill-but-just-output-the-pid-or-resource-id-don%27t-kill-595638/#post2941613 | |
wid=$(xwininfo |grep 'Window id:' |cut -d" " -f4) | |
pid=$(xprop -id "$wid" |grep "^_NET_WM_PID" | cut -d" " -f3) | |
echo $pid |grep '^ *[0-9][0-9]* *$' && exit 0 | |
cat <<EOF 1>&2 | |
xpid ERROR: can't get PID for selected window. | |
window ID: $wid | |
pid: $pid | |
EOF | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment