Before we dive into the code. Here is my xrandr script. I have three monitors two being 1080 and one being 4k. The 1080 monitors are positioned to the sides of the 4k monitor vertically while the 4k is in the centre horizontally.
--fb 8160x3840 will set the maximum frame buffer for the screen. If you have a 1080p monitor and you want to upscale it to 4k you will need to calculate the maximum vertical and horizontal buffer size.
If you have two 1080 monitors and a 4k monitor which are all aligned horizontally placed to the sides of each other and you want to upscale the two 1080s to 4k then your horizontal resolution will be
1920 * 2 + 3840 + 1920 * 2 which is
3840 + 3840 + 3840 or
Your vertical resolution will be the maximum resolution your monitors take up vertically just like your horizontal resolution.
--pos will position your display on the frame buffer. In my script I only modify the x axis. Each monitor is positioned to the right of the previous monitor. Because my first monitor is aligned vertically, I need to move the second monitor to the right, the horizontal space the first monitor takes is 2160 pixels which means I need to move the second monitor 2160 pixels to the right. The third monitor is
2160 + 3840 or
6000 pixels to the right.
--scale just scales the monitors, remember my side monitors are 1080p so they need to be scaled up to resemble 4k monitors.
--rotate rotates the monitors to the right and left to put them into vertical alignment.