polybar-themes
polybar-themes copied to clipboard
Multiple Monitors
How would i get this bar running on multiple monitors? I've trying setting environment variables but nothing has been working.
This isn't really a duplicate of #96 because I don't really understand how he did it and it wasn't much of a solution.
All I'm trying to do is get the shades theme applied on all 3 of my monitors.
Thanks, Sam.
Add at the end of config.ini of your theme:
[bar/secondary] inherit = bar/main monitor = DVI-I-0 ; <--- CHANGE TO YOUR SECONDARY MONITOR
; You can override any settings from bar/main here modules-left = workspaces sep cpu memory filesystem modules-center = date modules-right = temperature sep network sep volume sep updates sep sysmenu
Change in launch.sh of your theme:
polybar -q main -c "$DIR"/config.ini & polybar -q secondary -c "$DIR"/config.ini & <-- ADD THIS LINE
Repeat the same thing for any more bars you want to define
This should be added to ReadMe/Wiki
just modify the lauch.sh ~/.config/polybar/launch.sh
the changes i made to make it work:
launch_bar() {
killall -q polybar
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
if [[ "$style" == "hack" || "$style" == "cuts" ]]; then
polybar -q top -c "$dir/$style/config.ini" &
polybar -q bottom -c "$dir/$style/config.ini" &
elif [[ "$style" == "pwidgets" ]]; then
bash "$dir"/pwidgets/launch.sh --main
else
#👇 👉 launching multiple monitors --> make sure to add monitor = ${env:MONITOR:} in the config
if type "xrandr"; then
for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
MONITOR=$m polybar -q main -c "$dir/$style/config.ini" &
done
else
polybar -q main -c "$dir/$style/config.ini" &
fi
#polybar -q main -c "$dir/$style/config.ini" &
fi
}
we're using xrandr to get all the monitor configurations and then passing it on as an environment variable, which you have to accept in the config.ini
. Like for in this case main
is called.
so inside [bar/main]
:
change monitor =
into
monitor = ${env:MONITOR:}
Add at the end of config.ini of your theme:
[bar/secondary] inherit = bar/main monitor = DVI-I-0 ; <--- CHANGE TO YOUR SECONDARY MONITOR
; You can override any settings from bar/main here modules-left = workspaces sep cpu memory filesystem modules-center = date modules-right = temperature sep network sep volume sep updates sep sysmenu
Change in launch.sh of your theme:
polybar -q main -c "$DIR"/config.ini & polybar -q secondary -c "$DIR"/config.ini & <-- ADD THIS LINE
Repeat the same thing for any more bars you want to define
This doesn't work with the "hack" style.
Add at the end of config.ini of your theme: [bar/secondary] inherit = bar/main monitor = DVI-I-0 ; <--- CHANGE TO YOUR SECONDARY MONITOR ; You can override any settings from bar/main here modules-left = workspaces sep cpu memory filesystem modules-center = date modules-right = temperature sep network sep volume sep updates sep sysmenu Change in launch.sh of your theme: polybar -q main -c "$DIR"/config.ini & polybar -q secondary -c "$DIR"/config.ini & <-- ADD THIS LINE Repeat the same thing for any more bars you want to define
This doesn't work with the "hack" style.
https://github.com/adi1090x/polybar-themes/issues/116#issuecomment-815568129
:arrow_up:
this should fix it.. do note "hack" and "cuts" have top and bottom bars, so use
xrandr --query | grep " connected" | cut -d" " -f1
to find all the connected monitors and assign them into variables and change the config.ini accordingly
I add this script in my launch.sh
to launch polybar for multiple monitors:
DIS=$(xrandr --listactivemonitors | grep 'DP\|HDMI' | rev | cut -d ' ' -f1 | rev)
for mon in $DIS; do
MONITOR="$mon" polybar -q top -c "$DIR"/config.ini &
MONITOR="$mon" polybar -q bottom -c "$DIR"/config.ini &
done
I think it should be added in README.
I also made a launch script, though it works with all of the current themes. It also doesn't require xrandr
.
To apply it change the launch_bar
function in launch.sh
to this:
launch_bar() {
# 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 the bar
for m in $(polybar --list-monitors | cut -d":" -f1); do
if [[ "$style" == "hack" || "$style" == "cuts" ]]; then
MONITOR=$m polybar -q top -c "$dir/$style/config.ini" &
MONITOR=$m polybar -q bottom -c "$dir/$style/config.ini" &
elif [[ "$style" == "pwidgets" ]]; then
bash "$dir"/pwidgets/launch.sh --main
else
MONITOR=$m polybar -q main -c "$dir/$style/config.ini" &
fi
done
}
Then, in every config.ini
file in each theme folder, you must change the line that has monitor =
to monitor = ${env:MONITOR:}
.
After that you should be able to get your polybars displaying on each monitor.
You can modify every config.ini
using the following command when you're inside ~/.config/polybar
sed -i 's/^monitor =.*$/monitor = ${env:MONITOR:}/g' $(find . -type f -name "config.ini")