We have a computer running Ubuntu 22.04 LTS. It has four monitors and is part of a livestreaming setup. One monitor is on the left, and three monitors (a screen, a projector, and a HDMI-USB converter box that feeds a livestream camera input) are overlapped to all occupy the same screen area - any image on one shows on all. This is useful for projecting an image while simultaneously livestreaming it to a a remote audience. The setup is at a church and is sometimes run by volunteers. We are using a four-output Nvidia NVS 510 4 output HDMI card. I administer the system, but often volunteers or the minister run the setup - when there are no problems it all works fine.
Usually, all this kit works, an Xrandr command is run at startup after a brief delay and the screens show up in the right place.
However sometimes, not every time, the system boots and the screens are not superimposed per the xrandr command's specifications. Sometimes rebooting will restore them to the proper arrangement. When this error happens, we can't project and livestream the same images, as they are on three different virtual screens that are no longer superimposed.
What are some ways we can convince xrandr not to act randomly? Or a simple way that a non-linux-skilled volunteer can click something to fix the problem? Is the sleep command too short for reliability?
Here is the code that runs xrandr:
/etc/X11/Xsession.d/45custom_xrandr-settings
sleep 15
xrandr --output DP-1 --primary --mode 1280x1024 --output DP-0 --mode 1024x768 --right-of DP-1 --output DP-2 --mode 1024x768 --same-as DP-0 --output DP-3 --mode 1024x768 --same-as DP-0