home/.config/concession/services/20_polybar.dtf
2018-11-05 16:52:32 -06:00

47 lines
1.3 KiB
Bash

#! /usr/bin/env bash
#
# Simple wmstartup service
# Copyright (C) 2018 salt <salt@lap-th-e560-0>
#
# Distributed under terms of the MIT license.
#
service_name="Polybar"
service_process="polybar"
function start() {
# Make sure we have our xrdb stuff going
if $(which xrdbupdate) > /dev/null 2>&1; then
xrdbupdate > /dev/null 2>&1
fi
# Set some variables, if necessary
if [[ "$PB_BAR_BORDER_SIZE" == "" ]] && pgrep -U "$UID" 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
if pgrep -U "$UID" i3 > /dev/null 2>&1; then
export PB_WM_RESTACK="i3"
fi
# Spawn bars on the primary monitor
export PB_MONITOR=$(xrandr -q | awk '/primary/{print $1}')
svc_log "Starting primary bar(s) on monitor $PB_MONITOR"
svc_logstart polybar -r primary
svc_logstart polybar -r primary-2
# Spawn more for each secondary
export secondary_monitors=$(xrandr -q | grep ' connected' | grep -v 'primary' | awk '{print $1}')
if [[ "$secondary_monitors" == "" ]]; then
return 0
fi
for monitor in $secondary_monitors; do
svc_log "Starting secondary bar(s) on monitor $monitor"
PB_MONITOR=$monitor
svc_logstart polybar -r secondary
svc_logstart polybar -r secondary-2
done
return 0
}