[OPEN] How to open Polybar on one monitor of dual monitor setup

Post Reply
Poetician
Crewman
Posts: 112
Joined: Wed Sep 04, 2019 4:00 pm

[OPEN] How to open Polybar on one monitor of dual monitor setup

Post by Poetician »

I'm working on this one slowly, and help so far has fallen short. I have dual screens and dual Polybars. I'm trying this first in i3. I'd like the i3-extra bar to open only on the secondary, but it's looping and either appears as it normally would with a duplicate on each screen when I specify the monitor variable in the Polybar config; or with two on the secondary if I specify the monitor by it's name, in my case:

Code: Select all

monitor = DVI-D-0
So I'm guessing I need to stop the launch.sh loop and send the bar straight to secondary. That's where I'm stuck, which seems ridiculous, because it's a simplification. This might even be worth a video. Or you could make one instead. :)

In Git or the subReddit someone mentioned it would be cool if Polybar could handle multi-monitor internally. I concur ... All multi-monitor setups should be as simple as i3's.

I'll keep searching. I started this with the idea of three bars with distinct bottom bars to spread the modules around, then I had a better idea ... Remove modules and remove one bar.

I looked at everything in https://github.com/polybar/polybar/issues/763, and I obviously have a case of brain-lock for understanding the syntax, the language itself.
Ryzen 7 2700, 32GB Corsair Dominator 3200, MSI Armor RX-580, ASUS Crosshair Hero VII X470, Sabrent NVMe

Escudo
recruit crewman
Posts: 1
Joined: Sun Jun 26, 2022 8:57 pm

Re: [OPEN] How to open Polybar on one monitor of dual monitor setup

Post by Escudo »

I'll reply, even though it's a bit old, as I had a similar problem.

I just wanted to stop the error about the tray already being active, because it was loading it for all the bars - the polybar launch script gets called for each monitor, so it makes sense to add some logic to decide what bar to load; you can have multiple bar configurations in your config file.

I made a second bar config with the tray disabled. Next, I use xrandr to find the screen designated as primary - this one gets the argument to load the "mainbar" area of my config file. Anything else gets argument for the "secondbar" area:

This is changed in ~/.config/polybar/launch.sh

Code: Select all

 primary=$(xrandr --query |grep primary | cut -d" " -f1)
 
               if [[ $m = $primary ]]; then
                        MONITOR=$m polybar --reload mainbar-spectrwm -c ~/.config/polybar/config.ini &
                else
                        MONITOR=$m polybar --reload secondbar-spectrwm -c ~/.config/polybar/config.ini &
                fi
I am not 100% sure if a monitor gets the "primary" designation automatically. I have a xrandr command that runs much earlier to set up my screens.

Post Reply

Return to “Desktop environment”