bspwm: Make workspace assignment code to be proud of

This commit is contained in:
Salt 2018-08-01 19:38:52 -05:00
parent fd1836016a
commit 73315922ae

View File

@ -28,28 +28,22 @@ fi
unset dtfscript unset dtfscript
## bspwm GENERAL CONFIGURATION ## bspwm GENERAL CONFIGURATION
printf "[INFO] Configuring bspwm\n"
printf "[INFO] Setting up monitors\n" printf "[INFO] Setting up monitors\n"
monitors=$(bspc query -M | wc -l) # Get the primary first, to ensure it's the first element
monitors=($(xrandr -q | awk '/primary/{print $1}' && xrandr -q | grep ' connected' | grep -v 'primary' | awk '{print $1}'))
desktops=8 desktops=8
deskpermon=$(expr $desktops / $monitors) deskpermon=$(expr $desktops / ${#monitors[@]})
i=1 printf " [INFO] Putting $desktops desktops across ${#monitors[@]} monitors, $deskpermon each\n"
printf " [INFO] Putting $desktops desktops across $monitors monitors, $deskpermon each\n" for m in $(seq 0 $(expr ${#monitors[@]} - 1)); do
for monitor in $(xrandr -q | awk '/primary/{print $1}' && xrandr -q | grep ' connected' | grep -v 'primary' | awk '{print $1}'); do layout=$(seq --separator=" " $(expr 1 + $m) ${#monitors[@]} $(expr $desktops ))
until [[ "$(expr $i % \( $deskpermon + 1 \))" == "0" ]]; do printf " [INFO] Giving monitor $m (${monitors[$m]}) layout \"$layout\"\n"
layout="$layout $i" bspc monitor ${monitors[$m]} -d $layout
i=$(expr $i + 1)
done done
printf " [INFO] Giving monitor $monitor layout $layout\n"
bspc monitor $monitor -d $layout
layout="$i"
i=$(expr $i + 1)
done
unset layout
unset monitors unset monitors
unset desktops unset desktops
unset deskpermon unset deskpermon
printf "[INFO] Configuring bspwm\n"
bspc config border_width 4 bspc config border_width 4
bspc config window_gap 6 bspc config window_gap 6