I would like to have a more consistent behavior with a multi monitor setup. Right now, my default configuration is a two monitor setup with 4 desktop each, that is configured by typing:
bspc monitor eDP1 -d 1 2 3 4
bspc monitor HDMI1 -d 5 6 7 8
If I unplug the HDMI cable, all my 8 desktop are moved to eDP1, which is the only monitor available at that point, and this is fine with me.
Problem is, if I plug the HDMI cable again, what happens is that eDP1 will still hold all the desktops, while in HDMI1 a new desktop named Desktop appears. Is there any way for me to force bspwm to move desktops 5,6,7,8 to HDMI1 instead of creating a new one?
Similar problem arises if I boot my machine without the HDMI cable plugged. In that case, only four desktops are created in eDPI1, but if I plug my cable, instead of having four desktops there I have only the default Desktop desktop.
This is similar to https://github.com/baskerville/bspwm/issues/629, although unrelated.
Is there any way for me to force bspwm to move desktops 5,6,7,8 to HDMI1 instead of creating a new one?
You can have a script subscribe to xrandr or bspc monitor change events and move over the desktops if they exist.
Similar problem arises if I boot my machine without the HDMI cable plugged. In tha...
The same
You might try making your desktop initialization something like:
for monitor in $(bspc query -M); do
bspc monitor $monitor -d 1 2 3 4
done
so that when you plugin your new monitor you can just re-run your bspwmrc.
It works like a charm. Thank you!
I have another question on this regard.
I have made the following script to suit my needs (please tell me if it needs any improvement in your opinion, my bash experience is pretty basic):
#!/bin/bash
d1=0
d2=0
d3=0
d4=0
i=0
query=`bspc query -M --names`
read -a monitors <<<$query
if [[ ${#monitors[@]} == 1 ]]; then
for monitor in ${monitors[@]}; do
bspc monitor ${monitors[0]} -d 1 2 3 4 5 6 7 8
done
else
for monitor in ${monitors[@]}; do
let d1=${i}*4+1
let d2=${i}*4+2
let d3=${i}*4+3
let d4=${i}*4+4
bspc monitor $monitor -d $d1 $d2 $d3 $d4
let i++
done
fi
What it does, is to create desktop 1 2 3 4 5 6 7 8 if only one monitor is present, and four desktops per monitor if there are multiple monitors. And this works fine: I can attach/detach any monitor and by just relaunching the script everything works as expected.
My problem is at login. When I login (or boot), what happens is that only two desktops (named Desktop are created for each monitor. I suppose the reason is because bspc query -M --names does not return valid monitors because it is too early in the boot-up phase. How can I overcome this?
you could rely on monitor ID's instead of names -- that is, just switch bspc query -M --names to bspc query -M
I tried it now but it does not work. Same behavior as before: it works only if I manually run the script afterwards.
Update: it seems that the script is not launched at all. I added the following to the script:
touch /home/alecive/Desktop/foo
echo asofjidf >> /home/alecive/Desktop/foo
but foo is created only when I launch the script manually (with a sxhkd keyboard shortcut). It does not seem to be a permission issue, though. As you can see below, monitors.sh has the same permissions as the other scripts launched by bspwm:
(~/.config/bspwm) (master)
[alecive@malakim]$ ll
drwxr-xr-x 2 alecive dialout 4096 Apr 26 10:25 ./
drwx------ 71 alecive dialout 4096 Apr 18 10:28 ../
-rwxr-xr-x 1 alecive dialout 407 Apr 26 10:24 bspwmrc*
-rw-r--r-- 1 alecive dialout 8516 Jan 12 14:29 compton.conf
-rwxr-xr-x 1 alecive dialout 418 Apr 26 10:25 init.sh*
-rwxr-xr-x 1 alecive dialout 1862 Apr 26 10:25 monitors.sh*
-rwxr-xr-x 1 alecive dialout 6925 Jan 10 10:00 panel*
Ok fixed it. Apparently I had to put the full absolute path to monitor.sh in order for it to be found. It is something that I already had with the other scripts, but I forgot to add for this one.
Most helpful comment
You can have a script subscribe to xrandr or bspc monitor change events and move over the desktops if they exist.
The same
You might try making your desktop initialization something like:
so that when you plugin your new monitor you can just re-run your bspwmrc.