aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJopStro <[email protected]>2021-02-01 15:08:57 +0000
committerJopStro <[email protected]>2021-02-01 15:08:57 +0000
commitdadf868277c727afc4cc7fabc0f4ea1c2372d4c5 (patch)
tree38904e9d93ec4282e9a067a7151e8bc7b4188797
parent239d5ece0514ec5ad40a3ab0fbd088300a92497b (diff)
Add pid checking
-rwxr-xr-xbspswallow16
1 files changed, 14 insertions, 2 deletions
diff --git a/bspswallow b/bspswallow
index 35784a2..7525013 100755
--- a/bspswallow
+++ b/bspswallow
@@ -10,14 +10,26 @@ get_class() {
fi
}
+get_pid() {
+ xprop _NET_WM_PID -id "$1" | awk '/[0-9]{4}/ {print $3}'
+}
+
+get_ppid() {
+ ps -o ppid= -p $1
+}
+
+check_swallowing_process() {
+ [ -n $(get_pid $1) ] && return 0
+ [ "$(get_ppid "$(get_ppid "$(get_pid "$1")")")" = "$(get_pid "$2")" ] && return 0 || return 1
+}
+
swallow() {
addedtodesktop=$2
lasttermdesktop=$(bspc query -D -n last)
swallowerid=$1
swallowingid=$(bspc query -N -n last)
-
- if [ "$addedtodesktop" = "$lasttermdesktop" ]; then
+ if [ "$addedtodesktop" = "$lasttermdesktop" ] && check_swallowing_process "$swallowerid" "$swallowingid"; then
cat ~/.config/bspwm/noswallow ~/.config/bspwm/terminals | grep "^$(get_class "$swallowerid")$" && return
grep "^$(get_class "$swallowingid")$" ~/.config/bspwm/terminals || return
echo "$swallowerid $swallowingid" >> /tmp/swallowids