This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/apps/de/bspwm/config

53 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env sh
NUM_DESKTOPS="$(xrq bspwm.num_desktops || echo '10')"
REVERSE_DESKTOP_ORDERING="$(xrq bspwm.reverse_desktop_ordering)"
REVERSE_MONITOR_DESKTOPS="$(xrq bspwm.reverse_monitor_desktops)"
BSPWM_MONITORS=$(bspc query -M)
MONITOR_COUNT=$(echo "$BSPWM_MONITORS" | wc -w | awk '{ printf $1 }')
PER_MONITOR="$(xrq bspwm.num_desktops_per_monitor || echo $((NUM_DESKTOPS / MONITOR_COUNT)))"
DESKTOPS=$(seq "$NUM_DESKTOPS")
[ "$REVERSE_MONITOR_DESKTOPS" -eq 1 ] && BSPWM_MONITORS=$(echo "$BSPWM_MONITORS" | tac)
bspc config normal_border_color "$(xrq bspwm.normal_border_color)"
bspc config focused_border_color "$(xrq bspwm.focused_border_color)"
bspc config active_border_color "$(xrq bspwm.active_border_color)"
bspc config presel_feedback_color "$(xrq bspwm.presel_feedback_color)"
bspc config border_width "$(xrq bspwm.border_width)"
bspc config split_ratio "$(xrq bspwm.split_ratio)"
bspc config window_gap "$(xrq bspwm.window_gap)"
bspc config borderless_monocle true
bspc config gapless_monocle true
bspc config pointer_modifier "mod4"
bspc config remove_unplugged_monitors true
bspc config remove_disabled_monitors true
bspc rule -a "*" split_dir=right
i=1
total_screens=0
for mon in $BSPWM_MONITORS; do
max=$((i + PER_MONITOR - 1))
screens=""
for j in $(seq $i $max); do
[[ "$total_screens" -ge "$NUM_DESKTOPS" ]] || screens="${screens}${j} "
total_screens=$((total_screens+1))
echo $NUM_DESKTOPS $total_screens $screens
done
bspc monitor "$mon" -d $screens
i=$((max + 1))
done
if [ "$REVERSE_DESKTOP_ORDERING" -eq 1 ]; then
prev_mon=
for mon in ${BSPWM_MONITORS}; do
if [ ! -z $prev_mon ]; then
bspc monitor "$mon" --swap "$prev_mon"
fi
prev_mon="$mon"
done
fi
. maybe_source_env_file bspwm-after