连接外接显示器时如何修改xrandr采用的默认设置?

17 display-settings xrandr multi-monitor monitors display

在计算机打开时连接外接显示器时遇到问题。

在这一点上, xrandr 似乎采用了一种不起作用的组合。

作为另一个更大问题的解决方法,我希望能够在计算机运行时修改 xrandr 在连接外部显示器时的默认显示设置。(这样我就可以设置一个避免问题的设置:通过组合有效的分辨率,或者只启动一个显示器)。

如果我在启动系统之前连接外部显示器,xrandr 会选择以某种相当低的分辨率进行镜像显示。


更新:

xrandr
Screen 0: minimum 320 x 200, current 1360 x 768, maximum 4096 x 4096
VGA-0 connected 1360x768+0+0 (normal left inverted right x axis y axis) 580mm x 320mm
   1360x768       60.0*+
   1280x720       60.0  
   1024x768       60.0  
   800x600        60.3  
   640x480        60.0  
DVI-0 disconnected (normal left inverted right x axis y axis)
LVDS connected (normal left inverted right x axis y axis)
   1680x1050      60.1 +
   1400x1050      60.0  
   1280x1024      59.9  
   1440x900       59.9  
   1280x960       59.9  
   1280x854       59.9  
   1280x800       59.8  
   1280x720       59.9  
   1152x768       59.8  
   1024x768       59.9  
   800x600        59.9  
   848x480        59.7  
   720x480        59.7  
   640x480        59.4  
S-video disconnected (normal left inverted right x axis y axis)
Run Code Online (Sandbox Code Playgroud)

当我连接外部桌面时,我想以最佳分辨率使用它(考虑到我的另一个问题,不包括使用内部显示器)。我可以从 GUI 设置双显示器的分辨率。但是在连接外部显示器的电缆时,我希望内部关闭并且外部具有 1360x768 - 就像我运行xrandr上面的命令时一样。

nco*_*ers 1

我不知道如何编写xrandr连接外部显示器时的默认设置,但您可以轻松编写自定义脚本,然后将其关联到快捷键,例如meta + P.

例子

> nano  /usr/bin/custom-xrandr
#!/bin/bash
xrandr --output VGA1 --off --output HDMI1 --auto

> chmod u+x /usr/bin/custom-xrandr
Run Code Online (Sandbox Code Playgroud)

然后关联一些快捷方式/usr/bin/custom-xrandr,每次连接外部显示器时只需该键即可。

这应该完全达到你想要的效果。

  • 我目前没有遇到此类问题,但对于可能仍然存在这些问题的人(可能取决于某些过时的软件),您的解决方案很好。- 我现在看到的是,我使用的 Linux 系统是在连接外部显示器或使用 Meta-P 键循环显示器时自动采用正确的分辨率。如果默认情况下没有这样做,我最喜欢的解决方案是使用“分散”一键循环显示 - 更多信息[此处](http://unix.stackexchange.com/a/201961/32012)。 (2认同)