40 lines
1.1 KiB
Bash
Executable File
40 lines
1.1 KiB
Bash
Executable File
#! /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() {
|
|
# 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 bar(s) on monitor $PB_MONITOR"
|
|
polybar -r primary >/dev/null 2>/dev/null &
|
|
polybar -r primary-2 >/dev/null 2>/dev/null &
|
|
|
|
# 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
|
|
polybar -r secondary >/dev/null 2>/dev/null &
|
|
polybar -r secondary-2 >/dev/null 2>/dev/null &
|
|
done
|
|
return 0
|
|
}
|
|
|