diff options
| -rw-r--r-- | README.md | 2 | ||||
| -rwxr-xr-x | bspswallow | 16 | ||||
| -rwxr-xr-x[-rw-r--r--] | examples/scripts/noswallow_open | 2 |
3 files changed, 16 insertions, 4 deletions
@@ -28,4 +28,4 @@ Now just restart bspwm and you're good to go. # Known Issues * Incompatability with LibreOffice due to it having a splash screen and spawning multiple windows, use --no-logo when launching and turn off "Tip of the day" in order to avoid this issue. -* Due to the way the script works, programs opened with dmenu_run will still swallow the teminal. This issue can be avoided by using the script noswallow_dmenu in examples/scripts instead of dmenu_run. +* ~~Due to the way the script works, programs opened with dmenu_run will still swallow the teminal. This issue can be avoided by using the script noswallow_dmenu in examples/scripts instead of dmenu_run.~~ this is now only an issue with windows without the \_NET\_WM\_PID xproperty @@ -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 diff --git a/examples/scripts/noswallow_open b/examples/scripts/noswallow_open index 4521b11..81a2a0b 100644..100755 --- a/examples/scripts/noswallow_open +++ b/examples/scripts/noswallow_open @@ -2,6 +2,6 @@ # Prefix to a command to make it so that any windows spawned from it don't swallow the terminal # for launching things from sxhd etc killall bspswallow -eval "$1" >/dev/null +eval $@ >/dev/null sleep 2 bspswallow & |
