deskreen
deskreen copied to clipboard
Using xrandr to create a virtual display (Linux)
Creating a virtual display with xrandr that can be broadcasted as an extra monitor is fairly easy on Linux. I think that this method should be implemented as a guide as it is a viable method for Linux users without the need of extra drivers or a dummy plug. To achieve this I did the following:
First, run the following command:
xrandr
Command output
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
DisplayPort-1 disconnected (normal left inverted right x axis y axis)
DisplayPort-2 disconnected (normal left inverted right x axis y axis)
HDMI-A-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 521mm x 293mm
1920x1080 60.00*+ 71.91 50.00 59.94
1680x1050 59.88
1600x900 60.00
1280x1024 60.02
1440x900 59.90
1280x800 59.91
1280x720 60.00 50.00 59.94
1024x768 70.07 60.00
800x600 72.19 60.32 56.25
720x576 50.00
720x480 60.00 59.94
640x480 72.81 66.67 60.00 59.94
720x400 70.08
DVI-D-0 disconnected (normal left inverted right x axis y axis)
1920x1080 60.00
DP-1-4 disconnected (normal left inverted right x axis y axis)
HDMI-1-2 disconnected (normal left inverted right x axis y axis)
DP-1-5 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 531mm x 299mm
1920x1080 60.00*+
1680x1050 59.88
1280x1024 75.02 60.02
1440x900 74.98 59.90
1280x960 60.00
1280x800 59.91
1152x864 75.00
1024x768 75.03 70.07 60.00
832x624 74.55
800x600 72.19 75.00 60.32 56.25
640x480 75.00 72.81 66.67 59.94
720x400 70.08
DP-1-6 disconnected (normal left inverted right x axis y axis)
HDMI-1-3 disconnected (normal left inverted right x axis y axis)
1920x1080 (0x5b) 148.500MHz +HSync +VSync
h: width 1920 start 2008 end 2052 total 2200 skew 0 clock 67.50KHz
v: height 1080 start 1084 end 1089 total 1125 clock 60.00Hz
1680x1050 (0x5f) 119.000MHz +HSync -VSync
h: width 1680 start 1728 end 1760 total 1840 skew 0 clock 64.67KHz
v: height 1050 start 1053 end 1059 total 1080 clock 59.88Hz
1280x1024 (0x61) 108.000MHz +HSync +VSync
h: width 1280 start 1328 end 1440 total 1688 skew 0 clock 63.98KHz
v: height 1024 start 1025 end 1028 total 1066 clock 60.02Hz
1440x900 (0x62) 88.750MHz +HSync -VSync
h: width 1440 start 1488 end 1520 total 1600 skew 0 clock 55.47KHz
v: height 900 start 903 end 909 total 926 clock 59.90Hz
1280x800 (0x63) 71.000MHz +HSync -VSync
h: width 1280 start 1328 end 1360 total 1440 skew 0 clock 49.31KHz
v: height 800 start 803 end 809 total 823 clock 59.91Hz
1024x768 (0x67) 75.000MHz -HSync -VSync
h: width 1024 start 1048 end 1184 total 1328 skew 0 clock 56.48KHz
v: height 768 start 771 end 777 total 806 clock 70.07Hz
1024x768 (0x68) 65.000MHz -HSync -VSync
h: width 1024 start 1048 end 1184 total 1344 skew 0 clock 48.36KHz
v: height 768 start 771 end 777 total 806 clock 60.00Hz
800x600 (0x69) 50.000MHz +HSync +VSync
h: width 800 start 856 end 976 total 1040 skew 0 clock 48.08KHz
v: height 600 start 637 end 643 total 666 clock 72.19Hz
800x600 (0x6a) 40.000MHz +HSync +VSync
h: width 800 start 840 end 968 total 1056 skew 0 clock 37.88KHz
v: height 600 start 601 end 605 total 628 clock 60.32Hz
800x600 (0x6b) 36.000MHz +HSync +VSync
h: width 800 start 824 end 896 total 1024 skew 0 clock 35.16KHz
v: height 600 start 601 end 603 total 625 clock 56.25Hz
640x480 (0x6f) 31.500MHz -HSync -VSync
h: width 640 start 664 end 704 total 832 skew 0 clock 37.86KHz
v: height 480 start 489 end 492 total 520 clock 72.81Hz
640x480 (0x70) 30.240MHz -HSync -VSync
h: width 640 start 704 end 768 total 864 skew 0 clock 35.00KHz
v: height 480 start 483 end 486 total 525 clock 66.67Hz
640x480 (0x72) 25.175MHz -HSync -VSync
h: width 640 start 656 end 752 total 800 skew 0 clock 31.47KHz
v: height 480 start 490 end 492 total 525 clock 59.94Hz
720x400 (0x73) 28.320MHz -HSync +VSync
h: width 720 start 738 end 846 total 900 skew 0 clock 31.47KHz
v: height 400 start 412 end 414 total 449 clock 70.08Hz
Here I selected one of the disconnected outputs. For this example I am going to use DVI-D-0
If there is no output mode, one can be added with
xrandr --addmode DVI-D-0 1920x1080
# you may use the output you selected and the resolution you want
Next step is to identify the display you are going to use to position your new display. For example, I want to place my virtual display to the left of my primary display, which is HDMI-A-0, so I run the following command:
xrandr --output DVI-D-0 --mode 1920x1080 --left-of HDMI-A-0
# replace DVI-D-0 with the virtual output you selected
# and 1920x1080 with the resolution you chose on the previous command
# other options are --right-of, --above and --below
Finally, when running deskreen:
The virtual display is available (Screen 2).
If you want to disconnect the display, just run:
xrandr --output DVI-D-0 --off
I am willing to do a complete guide and open a pull request if you think it is a good enough method.
I think this seems like a good idea! I was a bit amused when I saw the requirement for a Display Dummy Plug, but it kind of defeats the purpose as I'd have to unplug my actual monitor (and buy a dummy) to do that — was thinking that surely this should be doable in pure software, at least on Linux where we should be able to hack around with anything we want...
I'll give this a try :)
For dummy video drivers check: xvfb and xorg-video-dummy AFAIK xrandr works on top of one of these
Hey everyone, I created a discussion thread for sharing knowledge on how to get rid from Display Dummy Plugs: https://github.com/pavlobu/deskreen/discussions/37#discussion-2016522
Feel free to comment there
Let me guess, this does not work with Wayland? (as it's called xrandr?)
Edit: I missed a crucial part of the cmd crisszkutnik gave, his solution works for me now and seems like the cleaner approach. I will leave the following here just so interested parties can follow the discussion.
First, thanks for the tool itself and for the trick to use xrandr without a dummy plug. However, your instructions did not work for me - after executing:
xrandr --addmode DVI-D-0 640x480
xrandr --output DVI-D-0 --right-of HDMI-A-0
I do get the following, as expected:
Screen 0: minimum 320 x 200, current 1680 x 1050, maximum 16384 x 16384
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
DisplayPort-1 disconnected (normal left inverted right x axis y axis)
HDMI-A-0 connected primary 1680x1050+0+0 (normal left inverted right x axis y axis) 473mm x 296mm
1680x1050 59.95*+
1280x1024 75.02 60.02
1440x900 59.95
1280x800 59.95
1152x864 75.00
1280x720 59.95
1024x768 75.03 60.00
800x600 75.00 60.32
640x480 75.00 59.94
720x400 70.08
HDMI-A-1 disconnected (normal left inverted right x axis y axis)
DVI-D-0 disconnected (normal left inverted right x axis y axis)
640x480 75.00
but deskreen does not show the newly created DVI-D-0. What did work for me was the following setup:
# --fb: set framebuffer big enough to hold real screen + additional screen to be shared by deskreen
# --panning: 1680x1050 is the actual resolution I want to use, the 2320x1050 (same as fb)
# describes the area in which the mouse may move. Without it, the second screen can be shared in
# deskreen, but the mouse pointer gets stuck at the border of the 'real' screen
xrandr --fb 2320x1050 --output HDMI-A-0 --panning 1680x1050/2320x1050
# create new monitor with 640x480 pixel and 64x48mm phyiscal size, place it right of real screen (1680)
xrandr --setmonitor virtual 640/64x480/48+1680+0 none
This can then be shared with deskreen. xrandr --listmonitors
then shows the new 'monitor':
Monitors: 2
0: +*HDMI-A-0 1680/473x1050/296+0+0 HDMI-A-0
1: virtual 640/64x480/48+1680+0
and xrandr --delmonitor virtual
removes it again.
First, thanks for the tool itself and for the trick to use xrandr without a dummy plug. However, your instructions did not work for me - after executing:
xrandr --addmode DVI-D-0 640x480 xrandr --output DVI-D-0 --right-of HDMI-A-0
You are missing the mode on the second command. It should be:
xrandr --output DVI-D-0 --mode 640x480 --right-of HDMI-A-0
Thanks! Now it works properly. And your solution seems like the cleaner one.
Using Nvidia with proprietary drivers (I don't know about Nouveau), xrandr --addmode
failas, as seen here. There is a workaround, but it's not great as in my case the mouse cursor flickers using this, and the windows leave trails on the virtual display (so it's not usable). So if anyone knows a workaround for such cases, please let me know.
Does anyone know a way to use this with an amd graphics card
is needed to have an free output to it works? here i cant use that to create a virtual screen
Hey @crisszkutnik I don't have a virtual screen right now. I know using 20-intel.conf I can add it but that seems to be tearing up my screen. I tried using HDMI outputs but the screen stays black. Any suggestions?
Creating a virtual display with xrandr that can be broadcasted as an extra monitor is fairly easy on Linux. I think that this method should be implemented as a guide as it is a viable method for Linux users without the need of extra drivers or a dummy plug. To achieve this I did the following:
First, run the following command:
xrandr
Command output
DisplayPort-0 disconnected (normal left inverted right x axis y axis) DisplayPort-1 disconnected (normal left inverted right x axis y axis) DisplayPort-2 disconnected (normal left inverted right x axis y axis) HDMI-A-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 521mm x 293mm 1920x1080 60.00*+ 71.91 50.00 59.94 1680x1050 59.88 1600x900 60.00 1280x1024 60.02 1440x900 59.90 1280x800 59.91 1280x720 60.00 50.00 59.94 1024x768 70.07 60.00 800x600 72.19 60.32 56.25 720x576 50.00 720x480 60.00 59.94 640x480 72.81 66.67 60.00 59.94 720x400 70.08 DVI-D-0 disconnected (normal left inverted right x axis y axis) 1920x1080 60.00 DP-1-4 disconnected (normal left inverted right x axis y axis) HDMI-1-2 disconnected (normal left inverted right x axis y axis) DP-1-5 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 531mm x 299mm 1920x1080 60.00*+ 1680x1050 59.88 1280x1024 75.02 60.02 1440x900 74.98 59.90 1280x960 60.00 1280x800 59.91 1152x864 75.00 1024x768 75.03 70.07 60.00 832x624 74.55 800x600 72.19 75.00 60.32 56.25 640x480 75.00 72.81 66.67 59.94 720x400 70.08 DP-1-6 disconnected (normal left inverted right x axis y axis) HDMI-1-3 disconnected (normal left inverted right x axis y axis) 1920x1080 (0x5b) 148.500MHz +HSync +VSync h: width 1920 start 2008 end 2052 total 2200 skew 0 clock 67.50KHz v: height 1080 start 1084 end 1089 total 1125 clock 60.00Hz 1680x1050 (0x5f) 119.000MHz +HSync -VSync h: width 1680 start 1728 end 1760 total 1840 skew 0 clock 64.67KHz v: height 1050 start 1053 end 1059 total 1080 clock 59.88Hz 1280x1024 (0x61) 108.000MHz +HSync +VSync h: width 1280 start 1328 end 1440 total 1688 skew 0 clock 63.98KHz v: height 1024 start 1025 end 1028 total 1066 clock 60.02Hz 1440x900 (0x62) 88.750MHz +HSync -VSync h: width 1440 start 1488 end 1520 total 1600 skew 0 clock 55.47KHz v: height 900 start 903 end 909 total 926 clock 59.90Hz 1280x800 (0x63) 71.000MHz +HSync -VSync h: width 1280 start 1328 end 1360 total 1440 skew 0 clock 49.31KHz v: height 800 start 803 end 809 total 823 clock 59.91Hz 1024x768 (0x67) 75.000MHz -HSync -VSync h: width 1024 start 1048 end 1184 total 1328 skew 0 clock 56.48KHz v: height 768 start 771 end 777 total 806 clock 70.07Hz 1024x768 (0x68) 65.000MHz -HSync -VSync h: width 1024 start 1048 end 1184 total 1344 skew 0 clock 48.36KHz v: height 768 start 771 end 777 total 806 clock 60.00Hz 800x600 (0x69) 50.000MHz +HSync +VSync h: width 800 start 856 end 976 total 1040 skew 0 clock 48.08KHz v: height 600 start 637 end 643 total 666 clock 72.19Hz 800x600 (0x6a) 40.000MHz +HSync +VSync h: width 800 start 840 end 968 total 1056 skew 0 clock 37.88KHz v: height 600 start 601 end 605 total 628 clock 60.32Hz 800x600 (0x6b) 36.000MHz +HSync +VSync h: width 800 start 824 end 896 total 1024 skew 0 clock 35.16KHz v: height 600 start 601 end 603 total 625 clock 56.25Hz 640x480 (0x6f) 31.500MHz -HSync -VSync h: width 640 start 664 end 704 total 832 skew 0 clock 37.86KHz v: height 480 start 489 end 492 total 520 clock 72.81Hz 640x480 (0x70) 30.240MHz -HSync -VSync h: width 640 start 704 end 768 total 864 skew 0 clock 35.00KHz v: height 480 start 483 end 486 total 525 clock 66.67Hz 640x480 (0x72) 25.175MHz -HSync -VSync h: width 640 start 656 end 752 total 800 skew 0 clock 31.47KHz v: height 480 start 490 end 492 total 525 clock 59.94Hz 720x400 (0x73) 28.320MHz -HSync +VSync h: width 720 start 738 end 846 total 900 skew 0 clock 31.47KHz v: height 400 start 412 end 414 total 449 clock 70.08Hz
Here I selected one of the disconnected outputs. For this example I am going to use DVI-D-0
If there is no output mode, one can be added with
xrandr --addmode DVI-D-0 1920x1080 # you may use the output you selected and the resolution you want
Next step is to identify the display you are going to use to position your new display. For example, I want to place my virtual display to the left of my primary display, which is HDMI-A-0, so I run the following command:
xrandr --output DVI-D-0 --mode 1920x1080 --left-of HDMI-A-0 # replace DVI-D-0 with the virtual output you selected # and 1920x1080 with the resolution you chose on the previous command # other options are --right-of, --above and --below
Finally, when running deskreen:
The virtual display is available (Screen 2).
If you want to disconnect the display, just run:
xrandr --output DVI-D-0 --off
I am willing to do a complete guide and open a pull request if you think it is a good enough method.
I need an free real display output?
Pretending there is a second monitor with xrandr seems to work. The big issue is that neither the DE nor software that should be able to use it seems to be able to see it.
For instance, on my system (linux, intel graphics) I can get the xrandr --addmode
+ xrandr --output
trick to add a a fake monitor area on the (unused) HDMI-2 port and to place it right of my laptop screen. Then Deskreen sees it.
Unfortunately KDE plasma only partially sees it:
- Yes, I can grab windows and move them out of the laptop window to the right, with the right border that stops from being active as a barrier that automaximizes windows that get into it;
- Yes, what I grab and move to the space right of my main screen can get transmitted "over the wire" by Deskreen;
- But, no, the DE does not work right with it: pop up menus keep appearing on the "real" laptop screen, the desktop pager does not show the enlarged virtual display area (and the system settings do not show the virtual monitor, but this is the lesser problem)
Most important Libreoffice does not see it at all:
- It is impossible to get a presentation to play in this virtual monitor keeping the presenter console on the main one or viceversa.
Note that the last point would be quite useful to do presentations with microsoft teams, etc. on linux where you would like to share the virtual screen.
Any clue? Do you really need a virtual HDMI adapter dongle?
Thank you so much for this guide! This worked like magic to my Thinkpad E495 Ryzen 5, KDE Neon 5.23.3 version, with an Ipad Pro 2020. I had to use HDMI-A-0 instead of the DVI, and then tell xrandr that it should replace it with eDP instead of the HDMI-A-0.
xrandr --addmode HDMI-A-0 1920x1080
xrandr --output HDMI-A-0 --mode 1920x1080 left-of eDP
I used xrandr --addmode HDMI-2 1920x1080
, xrandr --output HDMI-2 1920x1080 --right-of HDMI-1
and it didnt work, but then I ran xrandr --addmode DP-1 1920x1080
and it worked!
I use HP 250 G6 notebook
Works perfectly <3
It was very easy to get it working, thanks!
hello! I have a server and want to use my laptop as a display for it. This setup seems nice as i can just split-screen my display into two pieces. The only thing is that I don't want to use deskreen to extend my server display. I can get a VGA output from the server and plug it into the laptop, but the laptop refuses to acknowledge that the server is an input, not an output. Is there a way (using "xrandr" maybe), to tell the virtual second display to take input from my laptop's VGA plug?
It didn't work with my PC lol. My hardware: AMD 3700x + ASUS b450M pro s, Graphics card: hd6750.And my system is ubuntu 20.04 lts
cvt 1920 1080 60
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode DVI-0 "1920x1080_60.00"
xrandr --output DVI-0 --mode 1920x1080_60.00 --left-of HDMI-0
The command above does generate a virtual display, but the display shared by deskreen is messy. Both gtf and cvt are the same.
@oetwis I have try his method, It doesn't work for my PC too.
I think my hardware is too old. So it's more convenient for me to buy a graphics card deceiver directly.
"you may use the output you selected and the resolution you want"
I tried using Android device resolution (1080x2400) and failed with "xrandr cannot create mode", so I tried instead 1920x1080 and it works. At the end I couldn't select the resolution I want.
I wish I could see second screen with native android device resolution (1080x2400)
I haven't tried yet deskreen, but seeing here that WebRTCPipeWireCapturer
is mentioned, then something like the following should work for Sway (Wayland) if you have the ScreenCast portal working.
Note that you will to need to click on the invisible screen to select it.
$ swaymsg create_output && swaymsg output "HEADLESS-1" resolution 2048x1536
I actually used this with Sunshine (Moonlight), so it's working there, but the wrong resolution was detected by Sunshine / video compressor, so I still ended up with black bars when streaming to my iPad.
Is it possible to create a virtual display output on a headless system? For example I'm trying to create a virtual display for qemu/kvm ubuntu 21.10 guest VM but since the VM does not have any display device at all xrandr
outputs Can't open display
after executing xrandr --addmode DVI-D-0 1920x1080
.
wonderful works like magic! :)
In case you don't have any disconnected outputs when you run xrandr
, here's a workaround on how to create some for Ubuntu users.
If you're not an Ubuntu user and you don't have evdi
packaged, you may follow these steps:
- Download the latest release of evdi and unpack it.
-
cd
into themodule
directory and install it viadkms
. Here's a script to automate the process (mind thever
):
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "Superuser privilege is required, try \"sudo !!\"" 2>&1
exit 1
fi
name=evdi
ver=1.14.1
cp -r . /usr/src/${name}-${ver}
dkms add -m ${name} -v ${ver}
dkms build -m ${name} -v ${ver}
dkms install -m ${name} -v ${ver}
echo -e "\nFinished."
- Load the kernel module:
# modprobe evdi initial_device_count=2
- Restart Xorg (simply log out and log back in).
- Now run
xrandr
. You will see disconnected outputs. In my case:
DVI-I-2-2 disconnected (normal left inverted right x axis y axis)
DVI-I-1-1 disconnected (normal left inverted right x axis y axis)
To persist steps 3-4 across reboots, I needed to add this line
evdi
to /etc/modules-load.d/evdi.conf
and this line
options evdi initial_device_count=2
to /etc/modprobe.d/evdi.conf
.
P.S. @LJ-Court, I believe it answers your question.
Similar to this post I could only make it work with a resolution that's exactly the same as that of my primary monitor.
I set-up a small script to do this as:
virtualdisplayname=DisplayPort-0
resolution=1920x1080 # Same as the laptop's built in monitor
echo "Starting " $virtualdisplayname
xrandr --addmode $virtualdisplayname $resolution
xrandr --output $virtualdisplayname --mode $resolution --left-of eDP
deskreen
xrandr --output $virtualdisplayname --off
So this always works no problem, but when I try to set a smaller resolution (e.g. resolution=1280x720
) then I can't make screen extension work. The first steps run fine, the virtual display gets added, deskreen opens, but when I try to connect to the url that deskreen gives me I get a ERR_CONNECTION_REFUSED
error.
Is this expected? Is there a workaround?
This Does not work for me
When entering the following command xrandr --addmode DVI-D-0 1920x1080
I get the following error:
X Error of failed request: BadMatch (invalid parameter attributes) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 18 (RRAddOutputMode) Serial number of failed request: 41 Current serial number in output stream: 42
(I do have DVI-D-0 as an option, the 1920x1080 mode does exist)
I have POP Os 22.04 tls
I am using the proprietary drivers, version 515.65.01 (lastest at the time of writing this)
My xrandr output just shows two output modes, eDP-1 connected primary HDMI-1 connected
I don't have any free outputs, can I still add a virtual screen and connect it to my spare 10" android tablet ? Please help
Hello @Elkellympia @tomchor Can you help me, it's urgent.
Thanks and Regards,
My xrandr output just shows two output modes, eDP-1 connected primary HDMI-1 connected
I don't have any free outputs, can I still add a virtual screen and connect it to my spare 10" android tablet ? Please help
Hello @jakre1234 , i do not think so, i found this which may help you achieve that, but it depends on which gpu are you using (i think) , i do not know enough about xorg to help you in this
This causes the amdgpu driver to crash for me:
May 02 14:38:01 compooter kernel: ---[ end trace 0000000000000000 ]---
May 02 14:38:01 compooter kernel: RIP: 0010:resource_build_scaling_params+0x124/0x1090 [amdgpu]
May 02 14:38:01 compooter kernel: Code: 02 00 00 00 eb 0c b8 03 00 00 00 eb 05 b8 09 00 00 00 41 89 85 a8 00 00 00 49 8d 7d 10 48 89 54 24 40 48 89 b4 24 98 00 00 00 <8b> 46 54 8b 4e 6c 48 89 7c 24 18 01 86 3c 02 00 00 49 8b 45 08 01
May 02 14:38:01 compooter kernel: RSP: 0018:ffffa454c0bff808 EFLAGS: 00010246
May 02 14:38:01 compooter kernel: RAX: 0000000000000003 RBX: 0000000000000002 RCX: 0000000000000002
May 02 14:38:01 compooter kernel: RDX: ffff94a4ec65e400 RSI: 0000000000000000 RDI: ffff94a4fdf41368
May 02 14:38:01 compooter kernel: RBP: ffffa454c0bff9b8 R08: ffff94a4fdf40af0 R09: ffff94a3c9f60000
May 02 14:38:01 compooter kernel: R10: ffff94a4fdf40ad0 R11: 0000043700000000 R12: 0000000000000005
May 02 14:38:01 compooter kernel: R13: ffff94a4fdf41358 R14: 0000000000000006 R15: ffff94a4fdf401e8
May 02 14:38:01 compooter kernel: FS: 0000000000000000(0000) GS:ffff94a6defc0000(0000) knlGS:0000000000000000
May 02 14:38:01 compooter kernel: CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
May 02 14:38:01 compooter kernel: CR2: 0000000000000054 CR3: 00000001a5be2000 CR4: 0000000000750ee0
May 02 14:38:01 compooter kernel: PKRU: 55555554
May 02 14:38:01 compooter kernel: note: kworker/u32:12[190] exited with irqs disabled
May 02 14:38:01 compooter kernel: note: kworker/u32:12[190] exited with preempt_count 1