Low resolution dummy monitor for VNC when displayport unplugged

Okay, so to be clear, my issue was not that I couldn’t get a dummy monitor working, it was that I couldn’t get my system to switch between dummy monitor and real monitor depending on whether the display port connector was plugged in. I came up with a rather inelegant solution, but it seems to work:

dummy .conf file /etc/X11/xord.conf.d/97-dummy.conf.disabled

Section "Device"
    Identifier "dummy_videocard"
    Driver "dummy"
    Option "IgnoreEDID" "1"

Section "Monitor"
    Identifier "dummy_monitor"
    HorizSync 28.0-80.0
    VertRefresh 48.0-75.0
    Modeline "1280x720" 74.50 1280 1344 1472 1664 720 723 728 748 +HSync +VSync

Section "Screen"
    Identifier "dummy_screen"
    Device "dummy_videocard"
    Monitor "dummy_monitor"
    DefaultDepth 24
    SubSection "Display"
        Depth 24
        Modes "1280x720"

I added the following .desktop to ~/.config/autostart

[Desktop Entry]
Exec=sudo /usr/local/bin/vnc-display.sh
Name[en_CA]=monitor check
Name=monitor check
Comment[en_CA]=Check if display port monitor is plugged in and enable dummy for VNC if not
Comment=Check if display port monitor is plugged in and enable dummy for VNC if not

Then my script looks like this (log files just for my debugging):

# Check connected displays


if [ -e $DUMMY_DISABLED ]; then

  if xrandr | grep -q "DP-[0-9]\+\(\.[0-9]\+\)\? connected"; then
    # If yes, disable the dummy driver configuration by renaming the file
    echo "display port was detected" >> "$LOG_FILE"
    mv /etc/X11/xorg.conf.d/97-dummy.conf /etc/X11/xorg.conf.d/97-dummy.conf.disabled
    echo "display port was not detected" >> "$LOG_FILE"
    # If no, enable the dummy driver configuration by restoring the file
    mv /etc/X11/xorg.conf.d/97-dummy.conf.disabled /etc/X11/xorg.conf.d/97-dummy.conf
    #X :0 -config /etc/X11/xorg.conf.d/97-dummy.conf &
    sleep 30
    service gdm restart
    sleep 10

  mv /etc/X11/xorg.conf.d/97-dummy.conf /etc/X11/xorg.conf.d/97-dummy.conf.disabled

So now when I boot up, it looks for if the display port monitor is connected. If it isn’t, then it activates my dummy.conf file (by renaming) and restarts gdm.

I would love to know a better way – especially one that would allow hot plugging. I messed around with systemd services quite a bit, as well as other ways of autostarting, but it seems a whole bunch of stuff has to be up and running before I can detect the display port connection with xrandr, which is why I ended up going the .config/autostart route. I also couldn’t figure out how to detect the display port being plugged/unplugged.

Also, I’m not using vino-server.service because see here: Vino-server autostarting but then stopping automatically on Orin Nano - #7 by KevinFFF

vino-server is working fine for me when I use a ~/.config/autostart .desktop file to launch it.

These were issues I never had with my Xavier NX dev kit, so clearly things have changed with the Orin Nano dev kit.