xrandr virtual splitscreen cookbook
As of xrandr version 1.5 it has become easy to divide your physical monitors into smaller virtual monitors. This is done with the following commands (without the '' quotation marks), scroll down for examples, explanations and even further down for more information.
xrandr --setmonitor 'vn' 'vw'/'pw'x'vh'/'ph'+'wo'+'ho' 'od'
This commands creates a virtual monitor
vn virtual monitor name
vw virtual monitor width in pixels
pw physical width on monitor in milimeters
vh virtual monitor height in pixels
ph physcical heigt on monitor in milimeters
wo width offset of the virutal monitor
ho height offset of the virtual monitor
od output device, the physical monitor on which the virtual monitor will be projected, specify none if your previous virtual entry is projected on the same monitor
xrandr --fb 'tw'x'th'
This command sets the total resolution of all the screens
tw The total width off all virtual monitors + their width offsets combined
th The total height off all virtual monitors + their height offsets combined
xrandr --delmonitor 'vn'
This command deletes a monitor
vn virtual monitor name
Identify your monitors(s)
Run the command xrandr in your terminal, you should see a list with all your output devices and for connected devices their supported modi. For my system it looks like this (shortened);
$ xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
DVI-D-1 disconnected (normal left inverted right x axis y axis)
VGA-2 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 476mm x 268mm
...
VGA-1-1 connected (normal left inverted right x axis y axis)
...
HDMI-1-1 disconnected (normal left inverted right x axis y axis)
DP-1-1 disconnected (normal left inverted right x axis y axis)
HDMI-1-2 connected (normal left inverted right x axis y axis)
...
We can see I have three monitors connected on my system, but only one is turned on and displaying, that is VGA-2.
As you may notice it looks like a virtual screen which xrandr created by default, lets look closer.
VGA-2 connected primary 1920x1080+0+0 (...) 476mm x 268mm
VGA-2 is displaying a screen with resolution 1920 by 1080, with no offsets on either axis, on physical dimensions of 476mm by 268mm.
!! If nothing happens after commands
When upon entering --addmonitor commands nothing seems to happen, soft refresh xrandr by getting the current resolution from the first line of output of the xrandr command.
$ xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
...
And do, in this case, 1920 x (1080 + 1), so we have 1920 x 1081, we set the new master resolution with --fb to this, and then right after back to the original value.
xrandr --fb 1920x1081
xrandr --fb 1920x1080
On a single monitor
Split vertically
Let's split our monitor vertically right down the middle, the width of the two virtual monitors would be (1920px / 2) = 960px each, and their physical widths (476mm / 2) = 238mm each. We leave the heights untouched since we are not splitting horizontally.
VIRT-LEFT | VIRT-RIGHT | ||||
---|---|---|---|---|---|
width | height | width | height | ||
px | 960 | 1080 | 960 | 1080 | |
mm | 238 | 268 | 238 | 268 | |
offset | 0 | 0 | 960* | 0 |
* The virtual screen starts 960 pixels, the width of VIRT-LEFT, from the left side
The commands with the offsets in mind would be like this;
xrandr --setmonitor VIRT-LEFT 960/238x1080/268+0+0 VGA-2
xrandr --setmonitor VIRT-RIGHT 960/238x1080/268+960+0 none
Split vertically, and the right side horizontally
In total we will create three monitors, for the first virtual monitor on the left side, we split like the calculation above
VIRT-LEFT | ||
---|---|---|
width | height | |
px | 960 | 1080 |
mm | 238 | 286 |
offset | 0 | 0 |
Now we have 960px/1080px, 238mm/286mm left over to create our two monitors on the right side. But instead of dividing the width we will divide the height, (1080px / 2) = 540px and (286mm / 2) = 143mm. So the parameters, with all the offsets in mind would look like this.
VIRT-RIGHT-TOP | VIRT-RIGHT-BOT | ||||
---|---|---|---|---|---|
width | height | width | height | ||
px | 960 | 540 | 960 | 540 | |
mm | 238 | 134 | 238 | 134 | |
offset | 960* | 0 | 960* | 540** |
* The width offset 960 is carried over from the width of VIRT-LEFT
** The height offset is carried over from the height of VIRT-RIGHT-TOP
In commands
xrandr --setmonitor VIRT-LEFT 960/238x1080/286+0+0 VGA-2
xrandr --setmonitor VIRT-RIGHT-TOP 960/238x540/143+960+0 none
xrandr --setmonitor VIRT-RIGHT-BOT 960/238x540/143+960+540 none
On two or more monitors
Our final result will be the left screen split horizontally and the right screen vertically.
Make sure you have identified your physical monitors, if they have different physical dimensions in millimeters don't forget to change them in your calculations accordingly.
To keep the explanation simple I will stick to two physical monitors, which are extended horizontally (not mirrored) and where the primary display is the left monitor. You can change this in your desktop display manager.
The xrandr command outputs the following information about my two screens
$ xrandr
Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 16384 x 16384
VGA-2 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 476mm x 268mm
...
VGA-1-1 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 476mm x 268mm
...
We see xrandr is outputting a screen of 3840 by 1080 pixels which are my two monitors next to each other (1920 x 2) by 1080.
Now we split up our left monitor horizontally, so we divide the heights 1080px and 268mm by two, resulting;
VIRT-LEFT-TOP | VIRT-LEFT-BOT | ||||
---|---|---|---|---|---|
width | height | width | height | ||
px | 1920 | 540 | 1920 | 540 | |
mm | 476 | 134 | 476 | 134 | |
offset | 0 | 0 | 0 | 540* |
* The offset 540 is carried from the height of VIRT-LEFT-TOP
For the right monitor, we now divide the widths 1920px and 476mm by two and carry the width of VIRT-LEFT-* (1920px) as offset.
VIRT-RIGHT-LEFT | VIRT-RIGHT-RIGHT | ||||
---|---|---|---|---|---|
width | height | width | height | ||
px | 960 | 1080 | 960 | 1080 | |
mm | 238 | 286 | 238 | 268 | |
offset | 1920* | 0 | 2880** | 0 |
* The offset 1920 is carried over from the width of VIRT-LEFT-TOP
** The offset 2880 is carried by the sums of the widths of VIRT-LEFT-TOP and VIRT-RIGHT-LEFT
xrandr --setmonitor VIRT-LEFT-TOP 1920/476x540/143+0+0 VGA-2
xrandr --setmonitor VIRT-LEFT-BOT 1920/476x540/143+0+540 none
xrandr --setmonitor VIRT-RIGHT-LEFT 960/238x1080/268+1920+0 VGA-1-1
xrandr --setmonitor VIRT-RIGHT-RIGHT 960/238x1080/268+2880+0 none
Afterword
From my experience with the desktop environment Cinnamon from Linux Mint I come across some visual bugs, slow performance when moving or resizing windows, incorrect backgrounds but it works, compared to what I've tested on GNOME 3 of Ubuntu 18.04, where it doesn't seem to work at all.
Hey there. I'm just wondering what the limiting factor might be for scrollable virtual screen size. My gfx hardware says it can do 16384 x 16384 res. In practice though the computer locks up hard under a variety of distros at much less than half (1/4 total pixels) that res.
I have a 1920x1080 panel as my only monitor and am trying to simply have the largest pannable virtual screen I can.
I am taking google maps screen shots and stiching together to make a large wall sized map.
If you have any advice how to make it more stable or what the bottleneck would be then that would be really helpful.
Regards