5.4.Xorg 配置

5.4.1. 快速开始

Xorg 支持大多数常见的显卡、键盘和定点设备。

警告

会自动检测显卡、显示器和输入设备,无需任何手动配置。除非自动配置失败,否则不要创建 xorg.conf 或执行 Xorg -configure 操作。

5.4.1. 配置文件

Xorg 在多个目录中查找配置文件。FreeBSD 推荐将这些文件存放于 /usr/local/etc/X11/。使用此目录有助于将应用程序文件与操作系统文件相分离。

5.4.2. 单个或多个文件

使用多个文件,每个文件配置一个特定的设置,比使用传统的单个 xorg.conf 更方便。这些文件存储在主配置文件目录的 /usr/local/etc/X11/xorg.conf.d/ 子目录中。

提示

传统的单个 xorg.conf 仍然有效,但不像 /usr/local/etc/X11/xorg.conf.d/ 子目录中的多个文件那样清晰和灵活。

5.4.3. 显卡

可以在目录 /usr/local/etc/X11/xorg.conf.d/ 中指定显卡的驱动程序。

在配置文件中配置 Intel® 驱动:

例 14. 在文件中选择 Intel® 显卡驱动程序

/usr/local/etc/X11/xorg.conf.d/20-intel.conf

Section "Device"
        Identifier "Card0"
        Driver     "intel"
EndSection

在配置文件中配置 AMD® 驱动:

例 15. 在文件中选择 AMD® 显卡驱动程序

/usr/local/etc/X11/xorg.conf.d/20-radeon.conf

Section "Device"
        Identifier "Card0"
        Driver     "radeon"
EndSection

在配置文件中配置 NVIDIA® 驱动:

例 16. 在文件中选择 NVIDIA® 显卡驱动程序

/usr/local/etc/X11/xorg.conf.d/20-nvidia.conf

Section "Device"
        Identifier "Card0"
        Driver     "nvidia"
EndSection

在配置文件中设置 VESA 驱动:

例 17. 在文件中选择 VESA 显卡驱动程序

/usr/local/etc/X11/xorg.conf.d/20-vesa.conf

Section "Device"
  	  Identifier "Card0"
      Driver     "vesa"
EndSection

在配置文件中设置 SCFB 驱动:

例 18. 在文件中选择 SCFB 显卡驱动程序

/usr/local/etc/X11/xorg.conf.d/20-scfb.conf

Section "Device"
   	  Identifier "Card0"
      Driver     "scfb"
EndSection

如果需要配置多个显卡,可以添加 BusID。执行以下命令可以显示显卡总线 ID 列表:

% pciconf -lv | grep -B3 display

输出应类似于以下内容:

vgapci0@pci0:0:2:0:     class=0x030000 rev=0x07 hdr=0x00 vendor=0x8086 device=0x2a42 subvendor=0x17aa subdevice=0x20e4
    vendor     = 'Intel Corporation'
    device     = 'Mobile 4 Series Chipset Integrated Graphics Controller'
    class      = display
--
vgapci1@pci0:0:2:1:     class=0x038000 rev=0x07 hdr=0x00 vendor=0x8086 device=0x2a43 subvendor=0x17aa subdevice=0x20e4
    vendor     = 'Intel Corporation'
    device     = 'Mobile 4 Series Chipset Integrated Graphics Controller'
    class      = display

例 19. 在文件中选择 Intel® 显卡驱动程序和 NVIDIA® 显卡驱动程序

/usr/local/etc/X11/xorg.conf.d/20-drivers.conf

Section "Device"
   	  Identifier "Card0"
      Driver     "intel"
      BusID     "pci0:0:2:0"
EndSection

Section "Device"
   	  Identifier "Card0"
      Driver     "nvidia"
      BusID     "pci0:0:2:1"
EndSection

5.4.4. 显示器

几乎所有的显示器都支持扩展显示识别数据标准(EDID)。Xorg 使用 EDID 与显示器通信,检测支持的分辨率和刷新率。然后它选择最合适的设置组合来使用该显示器。

显示器支持的其他分辨率可以通过在配置文件中设置所需的分辨率来选择,或者在启动 X server 服务器之后用 xrandr(1) 配置。

5.4.4.1. 使用 RandR (调整大小和方向)

在不加任何参数的情况下运行 xrandr(1),可以看到视频输出和检测到的显示器模式的列表:

% xrandr

输出应类似于以下内容:

Screen 0: minimum 320 x 200, current 2560 x 960, maximum 8192 x 8192
LVDS-1 connected 1280x800+0+0 (normal left inverted right x axis y axis) 261mm x 163mm
   1280x800      59.99*+  59.81    59.91    50.00
   1280x720      59.86    59.74
   1024x768      60.00
   1024x576      59.90    59.82
   960x540       59.63    59.82
   800x600       60.32    56.25
   864x486       59.92    59.57
   640x480       59.94
   720x405       59.51    58.99
   640x360       59.84    59.32
VGA-1 connected primary 1280x960+1280+0 (normal left inverted right x axis y axis) 410mm x 257mm
   1280x1024     75.02    60.02
   1440x900      74.98    60.07
   1280x960      60.00*
   1280x800      74.93    59.81
   1152x864      75.00
   1024x768      75.03    70.07    60.00
   832x624       74.55
   800x600       72.19    75.00    60.32    56.25
   640x480       75.00    72.81    66.67    59.94
   720x400       70.08
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-2 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)

这表明,VGA-1 在使用屏幕分辨率为 1280x960 像素,刷新率约为 60 赫兹来进行显示输出。LVDS-1 在使用屏幕分辨率为 1280x960 像素,刷新率约为 60 赫兹作为副屏进行显示输出。显示器没有连接到 HDMI-1HDMI-2DP-1DP-2DP-3 接口。

其他任何显示模式都可以用 xrandr(1) 选择。例如,要切换到 60 赫兹的 1280x1024:

% xrandr --output LVDS-1 --mode 1280x1024 --rate 60

5.4.4.2. 使用 Xorg 配置文件

显示器配置也可以在配置文件中进行设置。

要在配置文件中设置 1024x768 的屏幕分辨率,请执行以下操作:

例 20. 在文件中设置屏幕分辨率

/usr/local/etc/X11/xorg.conf.d/10-monitor.conf

Section "Device"
   	Identifier "Screen0"
      Device     "Card0"
      SubSection "Display"
      Modes      "1024x768"
      EndSubSection
EndSection

5.4.5. 输入设备

Xorg 通过 x11/libinput 支持绝大多数输入设备。

提示

某些桌面环境(比如 KDE Plasma )提供了一个图形界面来设置这些参数。在进行手动配置编辑之前,请检查是否存在这种情况。

例如,配置键盘布局:

例 21. 设置键盘布局

/usr/local/etc/X11/xorg.conf.d/00-keyboard.conf

Section "InputClass"
        Identifier "Keyboard1"
        MatchIsKeyboard "on"
        Option "XkbLayout" "es, fr"
        Option "XkbModel" "pc104"
        Option "XkbVariant" ",qwerty"
        Option "XkbOptions" "grp:win_space_toggle"
EndSection

最后更新于

FreeBSD 中文社区