dtfscripts: Reconfigure Polybar depending on bspwm gap

This commit is contained in:
Salt 2018-08-29 23:13:56 -05:00
parent feac63577f
commit f14b2c3ade

View File

@ -10,11 +10,20 @@ service_name="Polybar"
service_process="polybar"
function start() {
# Set some variables, if necessary
if [[ "$PB_BAR_BORDER_SIZE" == "" ]] && pgrep bspwm > /dev/null 2>&1; then
if ! [[ "$BSPWM_WINDOW_GAP" == "" ]]; then
svc_log "Inferring bar size from BSPWM_WINDOW_GAP"
export PB_BAR_BORDER_SIZE="$BSPWM_WINDOW_GAP"
fi
fi
# Spawn bars on the primary monitor
export PB_MONITOR=$(xrandr -q | awk '/primary/{print $1}')
svc_log "Starting primary on monitor $PB_MONITOR"
polybar -r primary& > /dev/null 2>&1
polybar -r primary-2& > /dev/null 2>&1
# Spawn more for each secondary
export secondary_monitors=$(xrandr -q | grep ' connected' | grep -v 'primary' | awk '{print $1}')
if [[ "$secondary_monitors" == "" ]]; then
return 0