I'm on Ubuntu 20, I'm using i3 as windows manager on two monitors.
HDMI-1
is supposed to be my primary monitor on the left and VGA-1-1
is supposed to be on the right of it.
My first workspace (my terminal workspace) must open on the HDMI-1
and must perform a screenfetch
command. The other monitor must be on my second workspace (which is for Firefox).
I put the following config for i3 (.config/i3/config
):
set $workspace0 "0: Terminal"
set $workspace1 "1: Firefox"
exec --no-startup-id xrandr --output HDMI-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output DP-1 --off --output VGA-1-1 --mode 1920x1080 --pos 1920x0 --rotate normal
workspace $workspace0 output HDMI-1
workspace $workspace1 output VGA-1-1
exec --no-startup-id gnome-terminal -- zsh -c "screenfetch; zsh"
Here is my problem. This actually works like 60% of the time when I reboot.
Most of the time it works well.
But sometimes, my VGA-1-1
monitor just turn completely purple (which is the background of the Ubuntu 20 login screen). Sometimes I got my actual background and my status bar but nothing happens when I open something which is supposed to appear on this monitor (when I open Firefox for example, which is assign to $workspace1
).
My only solution then is to open arandr
and to change and save my settings. After saving my settings, xrandr resets and then I can finally see my VGA-1-1
with everything open on it.
I would like to understand what is currently going wrong. Why does it work sometimes and sometimes it doesn't? And more important: how can I fix this?
FYI: I use a polybar script executed it my i3 config before performing the xrandr command. I don't know if this may be related so I put it here just in case:
.config/i3/config
:
exec_always --no-startup-id $HOME/.config/polybar/dual_monitors.sh
.config/polybar/dual_monitors.sh
:
#!/usr/bin/env bash
killall -q polybar
echo "---" | tee -a /tmp/polybar_top-primary.log /tmp/polybar_top-secondary.log /tmp/polybar_bottom-primary.log /tmp/polybar_bottom-secondary.log
polybar top-primary >> /tmp/polybar_top-primary.log 2>&1 &
polybar top-secondary >> /tmp/polybar_top-secondary.log 2>&1 &
polybar bottom-primary >> /tmp/polybar_bottom-primary.log 2>&1 &
polybar bottom-secondary >> /tmp/polybar_bottom-secondary.log 2>&1 &
echo "Bars launched..."