legacy-dots

Unnamed repository; edit this file 'description' to name the repository.

.2bspwm

1.6 kB
 1#!/bin/sh
 2# neeasade
 3# makes dual borders
 4# depends on wmutils/opt
 5
 6# polyfill a script in my dots.
 7if ! type bspwindows >/dev/null; then
 8    bspwindows() {
 9	case "${1:-active}" in
10	    active)
11		bspc query -N -n .local.descendant_of.window.leaf.!fullscreen
12		;;
13	    inactive)
14		bspc query -N -n .local.!descendant_of.window.leaf.!fullscreen
15		;;
16	esac
17    }
18fi
19
20border_width_current=$(bspc config border_width)
21
22# half if even, 1px to outer if odd
23border_width_in_normal=$(( border_width_current/2 ))
24border_width_out_normal=$(( (border_width_current/2) + (border_width_current%2) ))
25border_width_in_focused=$border_width_in_normal
26border_width_out_focused=$border_width_out_normal
27
28border_color_in_normal=444444
29border_color_out_normal=eeeeee
30border_color_in_focused=888888
31border_color_out_focused=dddddd
32
33type theme >/dev/null 2>&1 && eval "$(theme get)"
34
35_chwb2() {
36    colorType=$1
37    shift
38    _getVal() {
39	eval echo \$${1}_${colorType}
40    }
41
42    [ "$width_normal" = "$width_focused" ] || \
43	echo "$@" | sed 's/ /\n/g' | xargs -I{} bspc config -n {} border_width $(_getVal width)
44
45    chwb2 -I $(_getVal border_color_in) -O $(_getVal border_color_out) -i $(_getVal border_width_in) -o $(_getVal border_width_out) $@ 2>/dev/null
46}
47
48width_normal=$((border_width_in_normal+border_width_out_normal))
49width_focused=$((border_width_in_focused+border_width_out_focused))
50bspc config border_width "$width_normal"
51
52_chwb2 focused $(bspwindows)
53_chwb2 normal $(bspwindows inactive)
54
55bspc subscribe node_state node_geometry node_focus | while read msg; do
56    _chwb2 focused $(bspwindows)
57    _chwb2 normal $(bspwindows inactive)
58done