Skip to content

Commit

Permalink
Use xdotool's getwindowpid instead of xprop
Browse files Browse the repository at this point in the history
  • Loading branch information
SeerLite committed Jul 31, 2020
1 parent f375bf9 commit 1a9ea60
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions pidswallow
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,13 @@ swallow() {
# return values
# 0 -> Found and swallowed
# 1 -> No swallowable window found.
# 2x -> xprop return a non zero exit code.(x is returned by xprop)
# 3 -> window lacks a _NET_WM_PID property.
# 4 -> window already swallowed
# 5 -> swallow_command failed
unset cwid pwid cname pname ppid cpid # similar to local.
cwid="$1"
[ -f "/tmp/swallowed-by-$cwid" ] && return 4
cpid="$(xprop _NET_WM_PID -id "$cwid" 2>/dev/null)" || return "2$?"
[ "${cpid#*not found*}" != "$cpid" ] && return 3 # window didn't have _NET_WM_PID
cpid="${cpid##* }"
cpid="$(xdotool getwindowpid "$cwid" 2>/dev/null)" || return 3
cname="$(ps -p "$cpid" -o comm=)"
[ "${blacklist#* $cname }" != "$blacklist" ] && return 0
process_tree="$(pstree -ATlsp "$cpid" \
Expand Down

0 comments on commit 1a9ea60

Please sign in to comment.