向日葵连接 Ubuntu 22.04 黑屏


问题: 该工具在服务器或工控机未连接显示器时,向日葵无法显示桌面。
原因分析
1. Xorg 依赖物理显示器
Xorg 设计时通常依赖物理显示器来初始化和正常运行。没有连接显示器,Xorg 可能无法正确初始化图形输出,进而导致向日葵远程桌面无法获取有效的图形数据来进行远程显示。
解决办法
1. 使用虚拟显示设备
可以通过安装和配置虚拟显示设备,让 Xorg 以为有显示器连接。以 xrandr 和 xserver-xorg-video-dummy 为例:
安装 xserver-xorg-video-dummy
sudo apt-get install xserver-xorg-video-dummy
查看显卡信息
使用 lspci 命令列出系统中所有的 PCI 设备,包括显卡。打开终端,输入以下命令:
lspci | grep -i vga
输出示例
tyz@tyz-desktop:~$ lspci | grep -i vga
00:02.0 VGA compatible controller: Intel Corporation CometLake-S GT2 [UHD Graphics 630](rev 05)
tyz@tyz-desktop:~$ # Intel UHD Graphics 630 显卡信息
基于显卡信息创建 Xorg 配置文件
请注意,在修改配置文件之前,建议备份原有的 xorg.conf 文件,以防出现问题可以恢复。
sudo cp /etc/X11/xorg.conf ~/xorg.conf.backup
以下是一个基于你提供的 Intel UHD Graphics 630 显卡信息,同时支持真实显示器和虚拟显示器的 /etc/X11/xorg.conf 文件示例:
# 真实显示器的配置
Section "Monitor"
Identifier "RealMonitor"
# 根据你的显示器实际支持的分辨率和刷新率调整
Option "PreferredMode"
HorizSync 28.0 - 80.0
VertRefresh 48.0 - 75.0
EndSection
Section
Identifier
Driver
Option
EndSection
Section
Identifier
Device
Monitor
DefaultDepth 24
SubSection
Depth 24
Modes
EndSubSection
EndSection
Section
Identifier
HorizSync 28.0 - 80.0
VertRefresh 48.0 - 75.0
Modeline 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
EndSection
Section
Identifier
Driver
VideoRam 256000
EndSection
Section
Identifier
Device
Monitor
DefaultDepth 24
SubSection
Depth 24
Modes
EndSubSection
EndSection
Section
Identifier
Screen 0 0 0
Screen 1 RightOf
Option
EndSection


