aboutsummaryrefslogtreecommitdiff
path: root/linux/home/.scripts/layer.sh
blob: 4b17ed186c80b44c0c7073f51aa73a6be8f06814 (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
#!/bin/bash

current_layer="$(bspc query -T -n | jq -r '.client.layer')"
case $1 in
    +|-)
        declare -A _layers=( [below]=0 [normal]=1 [above]=2 )
        layers=( below normal above )
        maxl=$(( ${#layers[@]} - 1 ))
        current_layer="$(bspc query -T -n | jq -r '.client.layer')"
        i=$(( ${_layers[$current_layer]} $1 1 ))
        if [[ $i -lt 0 ]]; then
            i=0
        elif [[ $i -gt $maxl ]]; then
            i=$maxl
        fi
        #cycle? nah
        #i=$(( (${_layers[$current_layer]} + ${#layers[@]} ${1} 1) % ${#layers[@]} ))
        new_layer="${layers[$i]}"
        ;;
    *)
        new_layer="$(bspc query -T -n | jq -r '.client.lastLayer')"
        ;;
esac
[[ "$current_layer" != "$new_layer" ]] && bspc node -l "$new_layer"