Polybar on Dual Monitors

Hello all,

Was wondering what the best way would be to configure polybar for two monitors. As it stands, I have my laptop screen which appears to have been auto assigned workspaces 1-4 and my external monitor is 4-8. However, the bar is on my external monitor, leaving my primary monitor without a bar Thoughts?


Let me show you mine…
Here is the config file

;     File Includes

include-file = /home/chris/.config/polybar/master.conf
include-file = /home/chris/.config/polybar/modules.conf

;     i3 Bars

inherit = bar/master

; Use $ xrandr -q | grep " connected" | cut -d ' ' -f1
monitor = eDP1

modules-left   = i3
modules-center = clock weather
modules-right  = mail battery cputemp volume

inherit = bar/master

; Use $ xrandr -q | grep " connected" | cut -d ' ' -f1
monitor = HDMI1

modules-left   = i3
modules-center = mpd clock weather
modules-right  = mail battery cputemp volume

Note where it says monitor ==
Thats where you define it. Then I simply duplicated bar/edp1 and created bar/hdmi1 and modified to my needs.

So no matter if the external is plugged in, you may want all the important stuff showing up on the main screen (your lappy) Pretty simple really :wink:

I forgot to mention that I created my own launcher:


# 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 Polybar, using default config location ~/.config/polybar/config
polybar eDP1 &
polybar HDMI1 &

echo "Polybar launched..."

chmod +x the script and mod the i3 config file to something like this:

# run with reload
#exec_always --no-startup-id al-polybar-session
exec_always --no-startup-id $HOME/.config/polybar/launch.sh

Note that I commented out the original line above mine.


I was actually (not intensively tho) looking for that, thanks for the time saving works :slight_smile:

That seemed to fix it thanks, however now I have lost my battery module. Thoughts?

Polybar launched…
┌ ~/.config/polybar
error: Disabling module “battery” (reason: No suitable way to get current charge state)

This is really good thanks!
I need a bit more info about this please.
Currently I’m on ArchLabs BSPWM and now I’m confused if I need two of every config file because I want to have 1 whole bar when I’m using laptop alone and two seperate bars when I connect two external monitors (laptop monitor off). I can understant code you posted, I could try it but I might need a little bit of help since I’m new to bash scripting but I’d love to learn.
Thanks in advance!