-
Notifications
You must be signed in to change notification settings - Fork 13
/
2bspwm
executable file
·49 lines (40 loc) · 1.41 KB
/
2bspwm
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
49
#!/usr/bin/env dash
# neeasade
# depends on: jq, colort, wmutils opt/chwb2
# makes dual borders based on your bspwm colors
focusedTint=70
normalTint=20
# set border widths, if odd outer is 1px larger
borderWidth=`bspc config border_width`
inWidth=$(( $borderWidth/2 ))
outWidth=$(( ($borderWidth/2) + ($borderWidth%2) ))
# _chwb2 [Focused|Normal] [nodeId]
_chwb2()
{
colorType=$1
shift
eval chwb2 -I \$inner$colorType -O \$outer$colorType -i $inWidth -o $outWidth $@ 2>/dev/null
}
# dec to hex
d2h() {
while read in; do
printf '0x%x\n' "$in"
done
}
# define border colors based on bspwm border settings
outerFocused=`bspc config focused_border_color | tr -d \#`
colort -c "$outerFocused" && sign=+ || sign=-
innerFocused=`colort -l $sign$focusedTint "$outerFocused"`
outerNormal=`bspc config normal_border_color | tr -d \#`
colort -c "$outerNormal" && sign=+ || sign=-
innerNormal=`colort -l $sign$normalTint "$outerNormal"`
# apply normal to all nodes, active to focused node.
_chwb2 Normal `bspc query -N -n .\!focused`
_chwb2 Focused `bspc query -N -n`
# react to resizes and focus changes
bspc subscribe node_geometry node_focus | while read msg; do
# everything not focused
_chwb2 Normal `bspc query -N -n .\!focused`
# any windows under focused node path
_chwb2 Focused `bspc query -T -n | jq '.. | .?, .root?, .firstChild?, .secondChild? | select (.client != null) | .id' | d2h`
done