如何设置登录脚本来运行 xrandr?

400*_*Cat 5 xrandr x-server

我正在使用 3 台显示器,其中 2 台正在旋转。

我无法成功配置xorg.conf以旋转 2 个显示器,但我找到了一个xrandr可以在登录管理器启动后使用的命令:

xrandr --output DisplayPort-1 --rotate right --left-of DisplayPort-0
xrandr --output DisplayPort-2 --rotate left --right-of DisplayPort-0
Run Code Online (Sandbox Code Playgroud)

目前,我在登录后手动运行这些命令。

我应该把这些放在哪里,以便我的显示器在登录时旋转。另外,我可以在全球范围内做吗?因此,当我以其他用户身份登录时,显示器会旋转。还是每个用户在登录后都需要一个用户脚本来执行此操作?

Pie*_*RET 4

我使用的是 2 个屏幕布局,与您的布局有点相似,我的布局是右侧的常规屏幕和左侧的纵向屏幕。通过我的设置,X 在我的 2 个屏幕上完美运行。

这是我针对您自己的情况提出的建议(很难测试,因为我没有相同的屏幕,也没有 3 个屏幕),但这应该足以让您获得有效的 X 设置。

将以下文件放入/etc/X11/xorg.conf.d/

30-screen-dport0.conf
30-screen-dport1.conf
30-screen-dport2.conf
Run Code Online (Sandbox Code Playgroud)

包含以下内容:

30-屏幕-dportcenter.conf

Section "Monitor"
  Identifier   "DisplayPort-0"
  Option       "Primary" "true"
  Option       "PreferredMode"   "3840x2160" # Adapt this if you resolution is not the same
  Option       "Position"        "1200 0" 
EndSection

Section "Screen"
  Identifier   "DPC"
  Device       "nVidia" # here you choose your driver
  Monitor      "DisplayPort-0"
EndSection
Run Code Online (Sandbox Code Playgroud)

30-screen-dportleft.conf

Section "Monitor"
  Identifier   "DisplayPort-1 "
  Option       "LeftOf" "DisplayPort-0"
  Option       "Rotate" "left" 
  Option       "PreferredMode"   "1920x1200"
  Option       "Position"        "0 0"
EndSection

Section "Screen"
  Identifier   "DPL"
  Device       "nVidia"
  Monitor      "DisplayPort-1"
EndSection
Run Code Online (Sandbox Code Playgroud)

30-screen-dportright.conf

Section "Monitor"
  Identifier   "DisplayPort-2"
  Option       "RightOf" "DisplayPort-0"
  Option       "Rotate" "right" 
  Option       "PreferredMode"   "1920x1200"
  Option       "Position"        "5040 0" # 1200 + 3840
EndSection

Section "Screen"
  Identifier   "DPR"
  Device       "nVidia"
  Monitor      "DisplayPort-2"
EndSection
Run Code Online (Sandbox Code Playgroud)

90-服务器布局.conf

Section "ServerLayout"
    Identifier   "Main"
    Screen       0 "DPL"
    Screen       1 "DPC"
    Screen       2 "DPR
EndSection
Run Code Online (Sandbox Code Playgroud)

Xserver 的坐标按以下方式工作

 0                 X
+ -----------------> X-axis 
|0
|
|
|
|
| 
| Y
V Y-axis  
Run Code Online (Sandbox Code Playgroud)

nVidia 标识符是对视频卡的引用,该视频卡定义在名为

20-nvidia.conf

Section "Device"
  Identifier  "nVidia"
  Driver      "nouveau"
  Option      "AccelMethod"  "sna"
  Option      "GLXVBlank"    "true"
  # Need to flag this as only referring to one output on the card
  Screen      0

EndSection
Run Code Online (Sandbox Code Playgroud)