From 9e1b4556d320d76047e095150712a60b14d70bc0 Mon Sep 17 00:00:00 2001 From: Salt Date: Wed, 1 Aug 2018 19:50:05 -0500 Subject: [PATCH] bspwm: Move monitor setup to its own file It's complex enough to warrant it, I'd say --- .config/bspwm/bspwmrc | 15 +-------------- .config/bspwm/monitorset.sh | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 14 deletions(-) create mode 100755 .config/bspwm/monitorset.sh diff --git a/.config/bspwm/bspwmrc b/.config/bspwm/bspwmrc index 9ab7e984..45c2dcdd 100755 --- a/.config/bspwm/bspwmrc +++ b/.config/bspwm/bspwmrc @@ -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 diff --git a/.config/bspwm/monitorset.sh b/.config/bspwm/monitorset.sh new file mode 100755 index 00000000..8c76f3e1 --- /dev/null +++ b/.config/bspwm/monitorset.sh @@ -0,0 +1,20 @@ +#! /bin/bash +# +# monitorset.sh +# Copyright (C) 2018 salt +# +# 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 +