diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-09-01 14:48:24 +0200 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-09-01 14:48:24 +0200 |
commit | 0c8f8c2728dfd1b74c616bfb64300b87132e272f (patch) | |
tree | e982481861152e3a67d5614d6038c15d19c41791 /bspwm/bspswallow | |
parent | uptodate doomrc (diff) | |
download | dotfiles-0c8f8c2728dfd1b74c616bfb64300b87132e272f.tar.gz dotfiles-0c8f8c2728dfd1b74c616bfb64300b87132e272f.tar.bz2 dotfiles-0c8f8c2728dfd1b74c616bfb64300b87132e272f.tar.xz dotfiles-0c8f8c2728dfd1b74c616bfb64300b87132e272f.tar.zst dotfiles-0c8f8c2728dfd1b74c616bfb64300b87132e272f.zip |
added papes, emacs theme & polybar colors
Diffstat (limited to 'bspwm/bspswallow')
-rwxr-xr-x | bspwm/bspswallow | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/bspwm/bspswallow b/bspwm/bspswallow new file mode 100755 index 0000000..832f191 --- /dev/null +++ b/bspwm/bspswallow @@ -0,0 +1,53 @@ +#!/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 + lasttermdesktop=$(bspc query -D -n last) + + swallowerid=$1 + swallowingid=$(bspc query -N -n last) + + if [ "$addedtodesktop" = "$lasttermdesktop" ]; then + grep "^$(get_class "$swallowerid")$" ~/.config/bspwm/swallow || return + grep "^$(get_class "$swallowingid")$" ~/.config/bspwm/terminals || return + echo "$swallowerid $swallowingid" >> /tmp/swallowids + bspc node "$swallowingid" --flag hidden=on + fi +} + +spit() { + spitterid=$1 + spitterdesktop=$2 + grep "^$spitterid" /tmp/swallowids || return + spittingid=$(grep "^$spitterid" /tmp/swallowids | head -n1 | awk '{print $2}') + + bspc node "$spittingid" --flag hidden=off + + termdesktop=$(bspc query -D -n "$spittingid") + [ "$termdesktop" = "$spitterdesktop" ] || bspc node "$spittingid" -d "$spitterdesktop" + + 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 " " $3}') + ;; + esac +done |