Polybar on Dual Monitors


#1

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?

Thanks!


#2

Let me show you mine…
Here is the config file

;=====================================================
;     File Includes
;=====================================================

[section/base]
include-file = /home/chris/.config/polybar/master.conf
include-file = /home/chris/.config/polybar/modules.conf


;=====================================================
;     i3 Bars
;=====================================================

[bar/eDP1]
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

[bar/HDMI1]
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:

UPDATE:
I forgot to mention that I created my own launcher:

#!/bin/bash

# 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.


#3

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


#4

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)