diff --git a/bspwm/.config/bspwm/bspwmrc b/bspwm/.config/bspwm/bspwmrc index dadf270..2b57c1d 100755 --- a/bspwm/.config/bspwm/bspwmrc +++ b/bspwm/.config/bspwm/bspwmrc @@ -99,3 +99,6 @@ xautolock -time 10 -locker ~/.local/bin/lock & ###---Misc---### # Needed for Jetbrains products to work wmname LG3D & + +# Enable bspswallow +pidof bspswallow || bash bspswallow & diff --git a/bspwm/.config/bspwm/noswallow b/bspwm/.config/bspwm/noswallow new file mode 100644 index 0000000..e69de29 diff --git a/bspwm/.config/bspwm/terminals b/bspwm/.config/bspwm/terminals new file mode 100644 index 0000000..9a3a072 --- /dev/null +++ b/bspwm/.config/bspwm/terminals @@ -0,0 +1,2 @@ +St +Alacritty diff --git a/bspwm/.local/bin/bspswallow b/bspwm/.local/bin/bspswallow new file mode 100755 index 0000000..97829db --- /dev/null +++ b/bspwm/.local/bin/bspswallow @@ -0,0 +1,47 @@ +#!/bin/sh + +# Get class of a wid +get_class() { + id=$1 + if [ -z $id ]; then + echo "" + else + xprop -id $id | sed -n '/WM_CLASS\|WM_COMMAND/s/.*"\(.*\)".*/\1/p' + fi +} + +swallow() { + addedtodesktop=$2 + echo $addedtodesktop + lasttermdesktop=$(bspc query -D -n prev) + echo $lasttermdesktop + swallowerid=$1 + swallowingid=$(bspc query -n prev -N) + if [ $addedtodesktop = $lasttermdesktop ]; 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 + bspc node $swallowingid --flag hidden=on + fi +} + +spit() { + spitterid=$1 + grep "^$spitterid" /tmp/swallowids || return + spittingid=$(grep "^$spitterid" /tmp/swallowids | head -n1 | awk '{print $2}') + bspc node $spittingid --flag hidden=off + bspc node $spittingid -f + sed -i "/^$spitterid/d" /tmp/swallowids +} + +bspc subscribe node_add node_remove | while read -r event; do + + case "$(echo $event | awk '{ print $1 }')" in + node_add) + swallow $(echo $event | awk '{print $5 " " $3}') + ;; + node_remove) + spit $(echo $event | awk '{print $4}') + ;; + esac +done