nicksheen
nicksheen

Reputation: 582

bspwm workspaces not working after activating other monitor

I'm using almost the default bspwmrcand sxhkdrc.

I'm working on a laptop and as far as I'm not connecting it to my monitor everything works just fine.

xrandr --output HDMI1 --mode 1920x1080 now breaks it. If I want to go to workspace one with Super+1 then nothing happens. Instead workspace one windows are now reachable on workspace two.

Thanks in advance!

Upvotes: 1

Views: 1680

Answers (1)

Abdullah Khabir
Abdullah Khabir

Reputation: 21

You have to decide on xrandr output how many monitors are attached while you start BSPWM. BSPWM is tiling window manager and it does its job very good.

 start_from=1
 monitors_connected=$(bspc query -M | wc -l)
 per_monitor=$(( 10 / monitors_connected ))
 for monitor in $(bspc query -M); do
    bspc monitor $monitor -d $(seq $start_from $(( start_from + per_monitor - 1)))
    start_from=$(( start_from + per_monitor ))
 done

In your case, it will put first 5 workspaces on the first monitor and other 5 on external monitor.

The code above you can include inside your bspwmrc before you start some status bar program.

while pgrep -x polybar >/dev/null; do sleep 1; done
  xrandr -q | awk '/ connected / {print $1}' | while read -r monitor _; do
  polybar -r "$monitor" & 
done

so polybar for every connected monitor will run. If there is only one monitor, nothing will happen.

Upvotes: 3

Related Questions