bspwm: Move monitor setup to its own file

It's complex enough to warrant it, I'd say
This commit is contained in:
Salt 2018-08-01 19:50:05 -05:00
parent 73315922ae
commit 9e1b4556d3
2 changed files with 21 additions and 14 deletions

View File

@ -29,20 +29,7 @@ unset dtfscript
## bspwm GENERAL CONFIGURATION
printf "[INFO] Configuring bspwm\n"
printf "[INFO] Setting up monitors\n"
# 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
deskpermon=$(expr $desktops / ${#monitors[@]})
printf " [INFO] Putting $desktops desktops across ${#monitors[@]} monitors, $deskpermon each\n"
for m in $(seq 0 $(expr ${#monitors[@]} - 1)); do
layout=$(seq --separator=" " $(expr 1 + $m) ${#monitors[@]} $(expr $desktops ))
printf " [INFO] Giving monitor $m (${monitors[$m]}) layout \"$layout\"\n"
bspc monitor ${monitors[$m]} -d $layout
done
unset monitors
unset desktops
unset deskpermon
$HOME/.config/bspwm/monitorset.sh
bspc config border_width 4
bspc config window_gap 6

20
.config/bspwm/monitorset.sh Executable file
View File

@ -0,0 +1,20 @@
#! /bin/bash
#
# monitorset.sh
# Copyright (C) 2018 salt <salt@dsk-cstm-0>
#
# Distributed under terms of the MIT license.
#
printf "[INFO] Setting up monitors\n"
# 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
deskpermon=$(expr $desktops / ${#monitors[@]})
printf " [INFO] Putting $desktops desktops across ${#monitors[@]} monitors, $deskpermon each\n"
for m in $(seq 0 $(expr ${#monitors[@]} - 1)); do
layout=$(seq --separator=" " $(expr 1 + $m) ${#monitors[@]} $(expr $desktops ))
printf " [INFO] Giving monitor $m (${monitors[$m]}) layout \"$layout\"\n"
bspc monitor ${monitors[$m]} -d $layout
done