我可以根据当前设置自动生成 xrandr 命令行吗?

Tim*_*ock 7 xrandr

不久前,我为我的双屏设置编写了一个设置脚本,因为当 X 变得疯狂时,我需要恢复理智,但我刚刚找到了一个备用显示器,并发现我可以从 USB-C 端口使用 DP我不知道我有。

我突然想到 xrandr 可能能够为当前设置创建自己的命令行,而不是我自己编写它,但我找不到任何选项。

有这个实用程序吗?这是一个愚蠢的想法吗?

Win*_*nix 5

~/.bashrc我之前遇到过同样的问题,导致我在调用中创建一个函数xreset

xreset () {

    xrandr --output HDMI-0  --mode 1920x1080 --pos 0x0       --rotate normal \
           --output eDP-1-1 --mode 1920x1080 --pos 3840x2160 --rotate normal \
           --output DP-1-1  --mode 3840x2160 --pos 1920x0    --rotate normal

} # xreset
Run Code Online (Sandbox Code Playgroud)

按位置和分辨率排列显示器后,使用以下命令获取当前设置:

$ xrandr | grep " connected"

HDMI-0 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 1107mm x 623mm
eDP-1-1 connected primary 1920x1080+3840+2160 (normal left inverted right x axis y axis) 382mm x 215mm
DP-1-1 connected 3840x2160+1920+0 (normal left inverted right x axis y axis) 1600mm x 900mm
Run Code Online (Sandbox Code Playgroud)

所有信息都可供您创建自己的xreset函数。


Tim*_*ock 4

啧。有时提出问题会给你带来不同的搜索词。

Arandr 是一个图形编辑器,允许您移动内容,但最相关的是它将 xrandr 命令行保存/导出为脚本:

xrandr \
   --output HDMI-2 --mode 3840x2160 --pos 0x48 --rotate normal \
   --output HDMI-1 --off \
   --output DP-1 --mode 3840x2160 --pos 5760x0 --rotate left \
   --output eDP-1 --primary --mode 1920x1080 --pos 3840x1528 --rotate normal \
   --output DP-2 --off
Run Code Online (Sandbox Code Playgroud)

我不需要“关闭”输出,但它们是无害的。