polybar-themes icon indicating copy to clipboard operation
polybar-themes copied to clipboard

Multiple Monitors

Open SamHep0803 opened this issue 3 years ago • 8 comments

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.

SamHep0803 avatar Apr 04 '21 20:04 SamHep0803

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

smoove avatar Apr 05 '21 12:04 smoove

This should be added to ReadMe/Wiki

ogost avatar Apr 06 '21 05:04 ogost

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:}

noel-johnson avatar Apr 08 '21 08:04 noel-johnson

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.

DrymarchonShaun avatar Apr 08 '21 22:04 DrymarchonShaun

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

noel-johnson avatar Apr 09 '21 03:04 noel-johnson

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.

asas1asas200 avatar Aug 09 '21 19:08 asas1asas200

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.

SuperMaZingCoder avatar Aug 10 '21 04:08 SuperMaZingCoder

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")

l3d00m avatar Nov 09 '22 11:11 l3d00m