Skip to content

Instantly share code, notes, and snippets.

@luisgabrielroldan
Last active June 11, 2020 21:01
Show Gist options
  • Save luisgabrielroldan/bbb412f116eed08ad33b906caf9d3482 to your computer and use it in GitHub Desktop.
Save luisgabrielroldan/bbb412f116eed08ad33b906caf9d3482 to your computer and use it in GitHub Desktop.
#!/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