-
-
Save binarynoise/0be82483f99db89d5ef59a940bd182c0 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# https://github.com/dianariyanto/virtual-display-linux/ | |
# https://bbs.archlinux.org/viewtopic.php?id=180904 | |
# https://unix.stackexchange.com/questions/378373/add-virtual-output-to-xorg | |
set -euo pipefail | |
set -x | |
resolution="1920x1080" | |
screen="HDMI-2" | |
echo "Configuring monitor $screen to $resolution" | |
if ! ( xrandr | grep -Pzo ".*$screen'.*\n(\s+.*\n)+" | grep -E "\s$resolution\s" ); then | |
if ! ( xrandr | grep -E "\s$resolution\s" ); then | |
xrandr --newmode $resolution $(cvt ${resolution/x/ } 60.02 | grep "^Modeline" | sed -E 's/Modeline\s+"[^"]+"\s+//') | |
fi | |
xrandr --addmode $screen $resolution | |
fi | |
xrandr --output $screen --mode $resolution --right-of eDP-1 | |
echo "started display $screen to $resolution" | |
trap "xrandr --output $screen --off &" 0 1 3 6 14 15 | |
killall /usr/bin/x0vncserver || true | |
echo "starting x0vncserver" | |
x0vncserver \ | |
-rfbauth ~/.vnc/passwd \ | |
-AcceptKeyEvents=off -AcceptPointerEvents=off -AcceptSetDesktopSize=off \ | |
-Geometry=$resolution+1920+0 \ | |
# -FrameRate 15 \ | |
xrandr --output $screen --off |
What is the output afterwards?
Exactly the same until starting x0vncserver
+ x0vncserver -rfbauth /home/sergio/.vnc/passwd -AcceptKeyEvents=false -AcceptPointerEvents=false -AcceptSetDesktopSize=false -Geometry=1920x1080+1920+0
New X0tigervnc server 'debian:0 (sergio)' on port 5900 for display :0.
Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/sergio/.vnc/passwd :0 to connect to the VNC server.
+ xrandr --output HDMI-2 --off
+ xrandr --output HDMI-2 --off
Connecting via a secondary device will give a time out.
Connecting locally will give a
CConn: unable to connect to socket: Connessione rifiutata (111)
I added --localhost no
to the tigervnc arguments and this got the VNC server to be visible, but the client will be immediately stopped as soon as an external device or the same device will try to connect to it with a CConn: End of stream
.
Every other attempt to connect from any device will fail with the same error listed in the message before (the server died?).
Removing +1920+0
from line 19 fixes the VNC server from crashing (but of course, it is just a mirror of the main screen). The X server is not drawing anything at all over the bounds of the main screen, as the system is still seeing only 1 screen.
Mmh. Seems it doesn't work for you. What does your vnc client display if you remove the geometry from the commandline when the virtual display is active?
Mmh. Seems it doesn't work for you. What does your vnc client display if you remove the geometry from the commandline when the virtual display is active?
My main screen only.
The problem is the virtual screen is never active. I never see it appear in my XFCE4 screen settings, nor can I move past my main screen boundaries.
It will appear as disconnected in xrandr but with an available video mode.
I never see it appear in my XFCE4 screen settings
I use cinnamon, but it won't appear in its display settings either. I can move windows over to the virtual monitor though, and in arandr
(like a gui for xrandr).
Maybe XFCE does some things different so it won't work. You maybe need a dummy HDMI plug
That's probably
xrandr --output HDMI-2 --mode 1920x1080 --right-of eDP-1
andxrandr --output HDMI-2 --mode 1920x1080 --right-of eDP-1
, turning the second monitor on and off.Looks like on Debian you need to replace off with false, on arch it accepts many variants.
What is the output afterwards?