aboutsummaryrefslogtreecommitdiff
path: root/bspswallow
diff options
context:
space:
mode:
Diffstat (limited to 'bspswallow')
-rwxr-xr-xbspswallow16
1 files changed, 14 insertions, 2 deletions
diff --git a/bspswallow b/bspswallow
index 51ed528..1466857 100755
--- a/bspswallow
+++ b/bspswallow
@@ -12,14 +12,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