adi1090x / polybar-themes

A huge collection of polybar themes with different styles, colors and variants.
GNU General Public License v3.0
5.6k stars 408 forks source link

How to launch polybars on more than one monitor? #96

Closed ameasere closed 3 years ago

ameasere commented 3 years ago

Hello,

I love these themes. I am using the "hack" theme and I tried editing the config and launcher like this:

# launch.sh inside /hack
# Add this script to your wm startup file. 

DIR="$HOME/.config/polybar/hack"

# 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
if type "xrandr"; then
  for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
    MONITOR=$m polybar -q topc -c "$DIR"/config/ini & && polybar -q bottom "$DI>
  done
else
  polybar --reload example &
fi
# Launch the bar
#polybar -q top -c "$DIR"/config.ini &
#polybar -q bottom -c "$DIR"/config.ini &
;This is the config.ini inside /hack
[bar/main]
; Use either of the following command to list available outputs:
; If unspecified, the application will pick the first one it finds.
; $ polybar -m | cut -d ':' -f 1
; $ xrandr -q | grep " connected" | cut -d ' ' -f1
monitor = ${env:MONITOR:} # this part was edited

For some reason, this doesn't work. I suck at bash, so I have no idea why this didn't work - I just took the topvoted answer lol. Please help!

ameasere commented 3 years ago

Update: Managed to get it to run with this in the config.ini:

DISPLAY1="$(xrandr -q | grep 'eDP' | cut -d ' ' -f1)"
[[ ! -z "$DISPLAY1" ]] && MONITOR="$DISPLAY1" polybar -q top -c "$DIR"/config.ini &
[[ ! -z "$DISPLAY1" ]] && MONITOR="$DISPLAY1" polybar -q bottom -c "$DIR"/config.ini &
DISPLAY2="$(xrandr -q | grep 'HDMI-A-0' | cut -d ' ' -f1)"
[[ ! -z "$DISPLAY2" ]] && MONITOR="$DISPLAY2" polybar -q top -c "$DIR"/config.ini &
[[ ! -z "$DISPLAY2" ]] && MONITOR="$DISPLAY2" polybar -q bottom -c "$DIR"/config.ini &