首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我重新启动Ubuntu22.04 VirtualBox时,我必须再次设置屏幕分辨率。我该怎么做才能维持这个决心?

当我重新启动Ubuntu22.04 VirtualBox时,我必须再次设置屏幕分辨率。我该怎么做才能维持这个决心?
EN

Ask Ubuntu用户
提问于 2022-09-16 13:10:46
回答 1查看 747关注 0票数 1

我已经在VirtualBox系统上安装了一个带有Gnome的新Ubuntu22.04服务器,每次重新启动时,屏幕的大小都会被重置为800x600 (登录屏幕和一旦登录)。

我将屏幕分辨率更改为1920x1600,这非常有用。我可以在没有问题的情况下使用这个系统好几天。

但是,下一次我重新启动时,这个更大的分辨率就丢失了。它将被重置回800x600。

我做错什么了吗?

注1:我可以看到~/.config/monitors.xml在那里,并且定义正确:

代码语言:javascript
复制
<monitors version="2">
  <configuration>
    <logicalmonitor>
      <x>0</x>
      <y>0</y>
      <scale>2</scale>
      <primary>yes</primary>
      <monitor>
        <monitorspec>
          <connector>Virtual-1</connector>
          <vendor>unknown</vendor>
          <product>unknown</product>
          <serial>unknown</serial>
        </monitorspec>
        <mode>
          <width>1920</width>
          <height>1200</height>
          <rate>59.884601593017578</rate>
        </mode>
      </monitor>
    </logicalmonitor>
  </configuration>
</monitors>

注2:正如在几个地方中提到的,我可以将monitors.xml文件复制到/var/lib/gdm3/.config/.,登录屏幕可以正常工作。但是一旦登录,这个分辨率就会再次丢失。

代码语言:javascript
复制
sudo cp ~/.config/monitors.xml /var/lib/gdm3/.config/.

注3:我有其他版本的Ubuntu (18.04,20.04),具有类似的设置,分辨率很好。

注4:我有一个“监视器”。

更新:

当我运行xrandr --verbose时,我看到这样的模式:

代码语言:javascript
复制
1920x1440 (0x53b) 233.500MHz -HSync +VSync *current +preferred
    h: width  1920 start 2064 end 2264 total 2608 skew    0 clock  89.53KHz
    v: height 1440 start 1443 end 1447 total 1493           clock  59.97Hz

我把它转换成这样的脚本:

代码语言:javascript
复制
xrandr --newmode "1920x1440_59.97"   233.50  1920 2064 2264 2608  1440 1443 1447 1493 -hsync +vsync
xrandr --addmode XWAYLAND0 1920x1440_59.97
xrandr --output XWAYLAND0 --mode 1920x1440_59.97

但是第一个也是最后一个xrandr会生成错误:

代码语言:javascript
复制
$ sh xrandr1.sh
X Error of failed request:  BadName (named color or font does not exist)
  Major opcode of failed request:  139 (RANDR)
  Minor opcode of failed request:  16 (RRCreateMode)
  Serial number of failed request:  20
  Current serial number in output stream:  20
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  139 (RANDR)
  Minor opcode of failed request:  7 (RRSetScreenSize)
  Serial number of failed request:  22
  Current serial number in output stream:  23

现在,我看到一些人对XWAYLAND0有异议。也许这就是我遇到的..。

在/var/log/syslog文件中可以找到一些日志:

代码语言:javascript
复制
Sep 15 23:31:47 ubuntu22 colord[2535]: failed to get edid data: EDID length is too small
Sep 15 23:31:47 ubuntu22 dbus-daemon[1214]: [system] Successfully activated service 'org.freedesktop.ColorManager'
Sep 15 23:31:47 ubuntu22 systemd[1]: Started Manage, Install and Generate Color Profiles.
Sep 15 23:31:47 ubuntu22 xbrlapi.desktop[2550]: openConnection: connect: No such file or directory
Sep 15 23:31:47 ubuntu22 xbrlapi.desktop[2550]: cannot connect to braille devices daemon brltty at :0
Sep 15 23:31:47 ubuntu22 /usr/libexec/gdm-wayland-session[2196]: dbus-daemon[2196]: [session uid=130 pid=2196] Successfully activated service 'org.gnome.ScreenSaver'
Sep 15 23:31:48 ubuntu22 gsd-color[2356]: failed to get edid: unable to get EDID for output
Sep 15 23:31:48 ubuntu22 gsd-color[2356]: unable to get EDID for xrandr-Virtual-1: unable to get EDID for output
Sep 17 01:10:40 ubuntu22 gnome-shell[2665]: XWAYLAND: mode 1024x600 is not available
Sep 17 01:16:20 ubuntu22 gnome-shell[2665]: message repeated 2 times: [ XWAYLAND: mode 1024x600 is not available]

最后一个似乎表明,默认情况下,系统需要一个名为Virtual-1的显示。不幸的是,我的显示器似乎被命名为XWAYLAND0。

在这方面,我还发现:

代码语言:javascript
复制
Sep 16 02:36:12 ubuntu22 gnome-shell[2303]: Registering session with GDM
Sep 16 02:36:12 ubuntu22 gnome-shell[1764]: Connection to xwayland lost
Sep 16 02:36:12 ubuntu22 gnome-session[1742]: gnome-session-binary[1742]: WARNING: Lost name on bus: org.gnome.SessionManager
Sep 16 02:36:12 ubuntu22 gnome-session-binary[1742]: WARNING: Lost name on bus: org.gnome.SessionManager

对于那个,我可以找到一个发射台上的错误

我试着关掉wayland但那没有帮助..。

代码语言:javascript
复制
[daemon]
# Uncomment the line below to force the login screen to use Xorg
WaylandEnable=false

...in表示,屏幕在重新启动时仍然会产生错误的分辨率。但是,xrandr命令现在起作用了。如果您想让它与Wayland一起工作,您可以使用gnome-randr.py脚本。请注意,我在更改WaylandEnable=false后重新启动了(我认为这是不言而喻的)。

EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2022-09-16 15:12:00

在“不优雅但有效”的修复类别中-

我也用一个VM来面对这个问题,它是一个屏幕大小奇怪的上网本的克隆。我无法让VM保留屏幕大小设置。因此,我编写了一个脚本来调整屏幕大小,并将脚本添加到启动项中。

在我的例子中,脚本是

代码语言:javascript
复制
xrandr --newmode "1024x600_60.00"   49.00  1024 1072 1168 1312  600 603 613 624 -hsync +vsync
xrandr --addmode Virtual1 1024x600_60.00
xrandr --output Virtual1 --mode 1024x600_60.00

你的价值观可能会有所不同。

票数 1
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1429717

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档