blob: 9f8acdf473b6bd0dcbd03d6cc2795d757bde5042 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/bin/sh
# Get class of a wid
get_class() {
id=$1
if [ -z $id ]; then
echo ""
else
xprop -id $id | sed -n '/WM_CLASS/s/.*, "\(.*\)"/\1/p'
fi
}
get_name() {
id=$1
if [ -z $id ]; then
echo ""
else
xprop -id $id | sed -n '/^WM_NAME/s/.*\(.*\) = "//p' | sed 's/"$//'
fi
}
swallow() {
swallowerid=$1
swallowingid=$(bspc query -n prev -N)
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
}
spit() {
spitterid=$1
grep "^$spitterid" /tmp/swallowids || return 0
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
if [ $(echo $event | awk '{ print $1 }') = node_add ]
then
swallow $(echo $event | awk '{print $5}')
else
spit $(echo $event | awk '{print $4}')
fi
done
|