-
-
Notifications
You must be signed in to change notification settings - Fork 716
Set polybar on multiple screens. #763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yes that's possible. The bar has a |
I have a if type "xrandr"; then
for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
MONITOR=$m polybar --reload example &
done
else
polybar --reload example &
fi And then in my polybar config, I have:
Works on every machine I've ever used it on, whether it was a multi-monitor setup or not :) |
Wonderfull!! |
I think we can close this |
To golf that down a little bit, you can dispense with the
|
I found this at ArchMergeD, credits to Erik for the basics, but enhanced it a bit, so that you can launch multible bars for different monitors. I just thought it could be useful for others. :)
Then, of course, in my polybar config file, i add multiple bars just like that:
|
Unfortunately it seems the tray can only be displayed on one polybar instance (and monitor) at a time. And when not specifying which monitor gets the tray it seems kind of random when using the above script. So, with thanks to @TobiasKB I'm now using the following script (executed by autorandr):
And relevant
My changes:
I still think it would be great if Polybar had built-in multi-monitor support. |
And, what if i have two bar? |
Using @lhanson 's response:
Simply call
|
Hello, inspired by what I read, a oneliner version with xargs and regexp: if type "xrandr">/dev/null; then
echo "Lanching polybar for each screen"
xrandr --listactivemonitors | grep -oP '(HDMI\-\d+$|eDP\-\d+$)' | xargs -P1 -I{} bash -c "MONITOR={} polybar -q -r p00 &"
fi |
Thought I would contribute my python script that solves the issue for me:
|
Instead if going around killing polybar, here's a more elegant solution that's also POSIX compliant:
Since it uses |
I am not a developer so there might be issues with the below code, but here's my take on it based on others' work above:
|
This is what I am using currently #!/usr/bin/env bash
# define bars per monitors
declare -A ARRANGEMENTS=(["DP-2"]="mm-top,mm-bottom" ["HDMI-0"]="rm-top")
# each key
for MONITOR in "${!ARRANGEMENTS[@]}"; do
# split at `,` into array
while IFS=',' read -ra BARLIST; do
# for each bar (seperated by `,`) at current key
for BAR in "${BARLIST[@]}"; do
MONITOR="$MONITOR" polybar --reload "$BAR" &
done
done <<< "${ARRANGEMENTS[$MONITOR]}"
done |
#763 (comment) |
@wouterhund ; thank you for the elegent script. I have never seen flock being used before. I'm trying to develop my version of your script; for which i launch multiple polybars (one top, one bottom and a top one for all the non-primary monitors) I understand the purpose of EDIT: I figured it out. You use it to close the file descriptor that the lock opened; since the lock would remain due to child process still is going on. (did not realize that detached children would still retain the lock) In my case; i spawn many child processes; and i don't know which is the final one to be. How I implemented the race lock was following (if anyone else is interested);
|
I have a question about this. I have a lot o bars for each monitor i have. Example:
I tried to do the following, but it didn´t work:
The errors are : Monitor:DP1=eDP1 order not found, Monitor:HDMI1=DP1 order not found, Monitor:DP1=DP1 order not found, Monitor:HDMI1=eDP1 order not found. I appreciate any help you can give me. |
This python script works well for me.
You can |
I don't understand what It should do... It shows me a cursor then I click and I get a syntactic error about 'Gdk' and `gi.require_version (" Gdk "," 3.0 ") '. Also I do not understand how I could put my eDP1(example and example2), DP1(example3 and example4) and HDMI1(example5 and example6) monitors with their respective bars that I just mentioned |
@ianmajkut The name of the environment variable isn't |
I am confused. I have duplicated my entry in my bars.ini and put this code in my config.ini and it still only stays on one monitor.
|
I got a bit of similar question. I have a two monitor setup (laptop + external screen) running i3 and i want my polybar to run on the second (attached) monitor, if it is connected, else on my laptop. So I did this in my config:
This works fine on startup and if i connect the second monitor manually and refresh i3/polybar. Nevertheless, if I plug my second monitor out, the polybar won't spawn on the laptop display. So i tried to track down why. The curious thing is, that if i use:
So now I am sitting here, wondering and asking myself how can i solve this and why polybar is still displaying a detached monitor after i plugged it put but not xrandr? Any help is appreciated! |
This uses XMonad.Hooks.ManageDocks to automatically create space in xmonad. The part of the script to deal with monitors is from polybar/polybar#763 (comment).
My better solution for people who are using autorandr:
|
I'm using the following in home manager atm: { pkgs, ... }: {
services.polybar.script = ''
# Launch bar on each monitor, tray on primary
polybar --list-monitors | while IFS=$'\n' read line; do
monitor=$(echo $line | ${pkgs.coreutils}/bin/cut -d':' -f1)
primary=$(echo $line | ${pkgs.coreutils}/bin/cut -d' ' -f3)
tray_position=$([ -n "$primary" ] && echo "right" || echo "none")
MONITOR=$monitor TRAY_POSITION=$tray_position polybar --reload top &
done
'';
} |
My test script to start MONITOR=HDMI-0 polybar --reload example &
MONITOR=DP-0 polybar --reload example & Error msg:
But the result is all polybar in one monitor |
I've just updated to the new tray module, I've adjusted my setup as follows: Startup script: # Launch bar on each monitor, tray on primary
polybar --list-monitors | while IFS=$'\n' read line; do
monitor=$(echo $line | cut -d':' -f1)
primary=$(echo $line | cut -d' ' -f3)
MONITOR=$monitor polybar --reload "top${primary:+"-primary"}" &
done Polybar config (irrelevant bits elided): [bar/top]
monitor=${env:MONITOR:}
modules-right=moduleA moduleB moduleC
[bar/top-primary]
inherit=bar/top
modules-right=moduleA moduleB moduleC tray
[module/tray]
type=internal/tray Essentially, I'm starting a different bar for the primary monitor, on which I want the tray to be placed. That bar inherits from the original bar's config, and then I overwrite |
I tried this, but I'm getting this warning: notice: Parsing config file: ~/.config/polybar/config.ini
error: Uncaught exception, shutting down: Undefined bar: top-primary. Available bars: monitor, mybar
notice: Parsing config file: ~/.config/polybar/config.ini
error: Uncaught exception, shutting down: Undefined bar: top. Available bars: monitor, mybar |
For those who like quick one-liners relying on GNU
and as an i3wm command:
|
I've been frustrated with the fragility of the shell scripts I use for I wrote a tool,
to put the main bar on the largest monitor and one instance of the secondary bar on each other connected monitor. Also supports using a TOML config file for an arbitrary number of commands in a single invocation. |
I have a setup with 3 monitors and i was wondering if it was possible to display polybar on all 3 monitors.
The text was updated successfully, but these errors were encountered: