AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-1697763

Lucas Scheepers's questions

Martin Hope
Lucas Scheepers
Asked: 2023-04-19 23:07:25 +0800 CST

Xrandr:无法打开显示(试图添加假显示)

  • 6

我已经在我的电脑上安装了 Ubuntu 22.04.2 LTS。有一种情况,当没有显示器连接到我的 GPU 时,我需要使用 Moonlight 和 Sunshine 访问这台 PC。Sunshine 是主机流媒体服务,Moonlight 是客户端服务。Sunshine 使用 Xorg 和 PulseAudio。当有显示器连接到我的 GPU 时,我已经在我的 PC 上成功启动了 Sunshine。只有这样我才能通过 Moonlight 连接到我的 PC。

如果没有连接监视器,Xorg 将无法启动,Sunshine 也将无法启动。我做了一些研究,我知道可以用一些 Xorg 配置和 edid.bin 文件伪造一个虚拟屏幕。

我事先断开了显示器的连接,并通过 SSH 会话访问了我的 PC。我遵循的步骤:

  1. 我已经为我的屏幕下载了这个 edid.bin 文件
  2. 我运行了以下命令: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. 我查看了/etc/X11/目录,发现创建了一个名为xorg.conf
  4. 该文件的内容如下所示:
# 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. 我通过运行以下命令检查了 Xorg 是否正在运行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. 我检查了/var/log/Xorg.0.log文件,没有发现错误。我还验证了屏幕已正确连接。

但是在运行命令后xrandr它返回Can't open display错误。我试过显示数字 0 到 10,但只有在xrandr --display :0它返回时:Authorization required, but no authorization protocol specified. Can't open display :0

我还尝试.Xauthority通过运行以下命令来编辑文件:xauth add :0 . $(xxd -l 16 -p /dev/urandom). 但是xrandr命令返回了Invalid MIT-MAGIC-COOKIE-1 key error

之后我删除了/etc/X11/xorg.conf文件和.Xauthority file. 然后再次连接我的显示器,使用我的显示器一切正常。我删除的那些文件也没有重新生成。没有这些文件怎么可能运行 Xorg?

那么有没有人知道如何在没有连接显示器时正确伪造这个 Xorg 屏幕,以便我可以启动 Sunshine 并通过 Moonlight 连接到我的 PC?如果您需要更多信息;请问!

编辑: 我通过运行命令禁用了 gdm sudo systemctl stop gdm,并使用以下命令手动启动了一个 Xorg 进程Xorg :0 -config xorg.conf -noreset。

所以我现在可以使用 xrandr 命令:

➜  ~ 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)

我仍然无法正确配置 gdm,因此它将启动一个 Xorg 进程以使用正确的 Xorg 配置将屏幕显示为数字 0

xorg
  • 1 个回答
  • 48 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve