Last active
June 11, 2020 21:01
-
-
Save luisgabrielroldan/bbb412f116eed08ad33b906caf9d3482 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
check-display() { | |
xrandr | grep $1 | grep " connected" | awk '{ print$1 }' | |
} | |
# 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 | |
DISPLAY1="$(check-display "eDP1")" | |
DISPLAY2="$(check-display "DP2")" | |
DISPLAY3="$(check-display "HDMI1")" | |
[[ ! -z "$DISPLAY1" ]] && MONITOR="$DISPLAY1" polybar main & | |
[[ ! -z "$DISPLAY2" ]] && MONITOR="$DISPLAY2" polybar extra & | |
[[ ! -z "$DISPLAY3" ]] && MONITOR="$DISPLAY3" polybar extra & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment