adi1090x / polybar-themes

A huge collection of polybar themes with different styles, colors and variants.
GNU General Public License v3.0
5.59k stars 406 forks source link

Multiple Monitors #116

Open SamHep0803 opened 3 years ago

SamHep0803 commented 3 years ago

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.

smoove commented 3 years ago

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

ogost commented 3 years ago

This should be added to ReadMe/Wiki

noel-johnson commented 3 years ago

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

DrymarchonShaun commented 3 years ago

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.

noel-johnson commented 3 years ago

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

asas1asas200 commented 2 years ago

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.

SuperMaZingCoder commented 2 years ago

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.

l3d00m commented 1 year ago

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