Skip to content

Instantly share code, notes, and snippets.

@albertogarrido
Created August 22, 2018 09:59
Show Gist options
  • Save albertogarrido/5bb2d6438a6315871dc5dbc3f1422dfa to your computer and use it in GitHub Desktop.
Save albertogarrido/5bb2d6438a6315871dc5dbc3f1422dfa to your computer and use it in GitHub Desktop.
#!/bin/bash
HDMI=$(xrandr | grep " connected " | grep "HDMI-0")
THUNDER=$(xrandr | grep " connected " | grep "^DP-1")
INTERNAL=$(xrandr | grep " connected " | grep "eDP-1")
# Terminate already running bar instances
killall -q polybar
# Wait until the processes have been shut down
while pgrep -x polybar >/dev/null; do sleep 1; done
if [ ${#HDMI} -gt 0 ]; then
xrandr --output eDP-1-1 --auto --output HDMI-0 --auto --right-of eDP-1-1
polybar -c /home/alberto/.config/polybar/config_hdmi_top main_bar &
elif [ ${#THUNDER} -gt 0 ]; then
xrandr --output eDP-1-1 --auto --output DP-1 --auto --right-of eDP-1-1
polybar -c /home/alberto/.config/polybar/config_hdmi_top main_bar &
elif [ ${#INTERNAL} ]; then
xrandr --output HDMI-0 --off
xrandr --output DP-1 --off
fi
polybar -c /home/alberto/.config/polybar/config_top main_bar &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment