Files
polybar/launch.sh

45 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
dir="$HOME/.config/polybar"
themes=(`ls --hide="launch.sh" $dir`)
launch_bar() {
if [ -e "$dir/$style/config.ini" ]; then
# Terminate already running bar instances
killall -q polybar
# Wait until the processes have been shut down
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
# Launch the bar multi monitor aware
primary=$(xrandr --query | grep "connected" | grep "primary" | cut -d \ -f1)
for mon in $(polybar --list-monitors | cut -d":" -f1); do
if [[ "$style" == "hack" || "$style" == "cuts" ]]; then
MONITOR=$mon TRAY_POS=$tray_pos polybar -q top -c "$dir/$style/config.ini" &
MONITOR=$mon polybar -q bottom -c "$dir/$style/config.ini" &
else
# If primary monitor load up [bar/primary] instead of [bar/main]
if [ "$mon" = "$primary" ]; then
MONITOR=$mon polybar -q primary -c "$dir/$style/config.ini" &
else
MONITOR=$mon polybar -q main -c "$dir/$style/config.ini" &
fi
#MONITOR=$mon TRAY_POS=$tray_pos polybar -q main -c "$dir/$style/config.ini" &
fi
done
else
echo "$dir/$style/config.ini" not found
exit 1
fi
}
if [ "$1" = "" ]; then
echo "Please specify a --style"
exit 1
fi
style=${1#--*}
launch_bar