sudo apt-get install xserver-xorg-video-dummy
Create / Edit xorg.conf file Rename file if already exists for backup
sudo vi /usr/share/X11/xorg.conf.d/xorg.conf
Add the following content to the file Set the resolution to what you like (whatever resolution the screen is that is used to connect remotely is probably is a good idea)
Section "Device"
Identifier "Configured Video Device"
Driver "dummy"
EndSection
Section "Monitor"
Identifier "Configured Monitor"
HorizSync 31.5-48.5
VertRefresh 50-70
EndSection
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1920x1080"
EndSubSection
EndSection
Save the file Reboot and Test
After fighting with this for hours, I made a few tweaks to get around the "can't open display " error.
First:
I used the answer here: https://askubuntu.com/questions/1274241/xrandr-script-for-external-monitor-adjustment-not-executing-from-udev and used a different IF statement that looks for the connection status in /sys/class/drm. My machine only has 1 DisplayPort so I only need to check one place for the status.
DP_Status= cat /sys/class/drm/card0-DP-1/status if [ $DP_Status = "connected" ] then sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.bak else sudo mv /etc/X11/xorg.conf.bak /etc/X11/xorg.conf sudo X :0 -config /etc/X11/xorg.conf & fi
Second:
The script correctly updated the xorg.conf file, but on boot, it was still loading when connected to DisplayPort.
I assumed the script was running after the xorg.conf file was loaded because it had been updated to xorg.conf.bak. I changed the after statement in the vnc-display.service to
After=systemd-user-sessions.service
I grabbed the same after service as the display manger.
I also changed the x11vnc.service:
Requires=vnc-display.service After=vnc-display.service
Now, when I boot without displayport connected, it loads the dummy display and if I boot with displayport connected, it uses displayport.