2

I've installed Ubuntu 22.04.2 LTS on my PC. There's a scenario that I need to access this PC using Moonlight and Sunshine when there's no monitor connected to my GPU. Sunshine is the host streaming service and Moonlight the client service. Sunshine uses Xorg and PulseAudio. I've started Sunshine successfully on my PC when there's a monitor connected to my GPU. Only then I'm able to connect to my PC via Moonlight.

If there's no monitor connected Xorg fails to start and so does Sunshine. I've done some research and I know it's possible to fake a dummy screen with some Xorg configuration and an edid.bin file.

I disconnected the monitor beforehand and got access to my PC via a SSH session. The steps I followed:

  1. I've downloaded this edid.bin file for my screen
  2. I ran the following command: sudo nvidia-xconfig -a --allow-empty-initial-configuration --use-display-device="DP-0" --connected-monitor="DP-0" --custom-edid="DP-0:/home/$USER/edid-2.bin"
  3. I looked in the /etc/X11/ directory and found there's a file created called xorg.conf
  4. The contents of the file looks like this:
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 525.105.17

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "NVIDIA GeForce RTX 3060 Ti"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "AllowEmptyInitialConfiguration" "True"
    Option         "UseDisplayDevice" "DP-0"
    Option         "CustomEDID" "DP-0:/home/lucas/edid-2.bin"
    Option         "ConnectedMonitor" "DP-0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

  1. I've checked if Xorg is running by running the following command: ps aux | grep xorg:
root        1241  0.1  0.1 25349916 53660 tty1   Sl+  15:48   0:00 /usr/lib/xorg/Xorg vt1 -displayfd 3 -auth /run/user/127/gdm/Xauthority -nolisten tcp -background none -noreset -keeptty -novtswitch -verbose 3
lucas       2392  0.0  0.0   9216  2432 pts/0    S+   15:50   0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox xorg
  1. I've checked the /var/log/Xorg.0.log file and found no errors. I also validated the screen was correctly connected.

But after running the command xrandr it returns the Can't open display error. I've tried display number 0 to 10 and only at xrandr --display :0 it returns: Authorization required, but no authorization protocol specified. Can't open display :0

I've also tried to edit the .Xauthority file by running the following command: xauth add :0 . $(xxd -l 16 -p /dev/urandom). But the xrandr command returned the Invalid MIT-MAGIC-COOKIE-1 key error

Afterwards I deleted the /etc/X11/xorg.conf file and the .Xauthority file. Then connected my monitor again and everything works fine again using my monitor. Also those files I deleted weren't regenerated. How's is it even possible to run Xorg without those files?

So does anyone have an idea how to properly fake this Xorg screen when no monitor is connected so that I can launch Sunshine and connect via Moonlight to my PC? If you need some more information; please ask!

EDIT: I've disabled gdm by running the command sudo systemctl stop gdm and started manually a Xorg process with the following command Xorg :0 -config xorg.conf -noreset.

So I can use the xrandr command now:

➜  ~ xrandr --display :0
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
HDMI-0 disconnected primary (normal left inverted right x axis y axis)
DP-0 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 500mm x 281mm
   1920x1080     60.00*+
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)

I'm still not able to configure gdm correctly so it will start a Xorg process to display the screen to number 0 with the correct Xorg configuration

1 Answer 1

1

Well I found a solution.

  1. Disable GDM (GNOME display manager) --> sudo systemctl disable gdm && sudo systemctl stop gdm. (Be aware that you'll need GDM if you connect to a physical monitor)
  2. Move /etc/X11/xorg.conf to /etc/X11/sunshine/xorg.conf
  3. Create systemd service --> /etc/systemd/system/xorg.service. The contents of the xorg.service file:
[Unit]
Description=Xorg Server
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/Xorg :0 -config /etc/X11/sunshine/xorg.conf -nolisten tcp

[Install]
WantedBy=multi-user.target
  1. Enable the xorg.service --> sudo systemctl enable xorg && sudo systemctl start xorg
  2. sudo reboot
  3. After rebooting the PC I can successfully use the xrandr --display :0 command. By setting the environment variable DISPLAY you don't need the --display flag anymore

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .