Polybar: Fix erroneous fallback, add logging

This commit is contained in:
Salt 2019-07-04 15:15:54 -05:00
parent d93e7bc530
commit 748d8ad04d

View File

@ -7,6 +7,11 @@
# Distributed under terms of the MIT license.
#
log() {
[ -z "$1" ] && return 1
printf "$1\\n"
}
# Trap our exit
die() {
kill $(jobs -p)
@ -17,10 +22,12 @@ trap die EXIT
step_fallback() {
if ! command -v polybar > /dev/null 2>&1; then
if command -v tint2 > /dev/null 2>&1; then
log "Executing fallback"
exec tint2
fi
log "No valid bars found"
exit 51
fi
exit 51
}
step_configure_restack() {
# Restack compatibility
@ -32,12 +39,14 @@ step_configure_restack() {
}
step_spawn_primary() {
# Spawn bars on the primary monitor
log "Spawning primary bars"
export PB_MONITOR=$(xrandr -q | awk '/primary/{print $1}')
polybar -r primary &
polybar -r primary-2 &
}
step_spawn_secondary() {
# Spawn more for each secondary
log "Spawning secondary bars"
export secondary_monitors=$(xrandr -q | grep ' connected' | grep -v 'primary' | awk '{print $1}')
if [ "$secondary_monitors" == "" ]; then
return 0
@ -50,6 +59,7 @@ step_spawn_secondary() {
}
step_wait() {
# And wait
log "Waiting"
wait
}