生成X server配置文件
生成Xserver配置文件要在字符界面才能生成,在图形界面生成会报错。
第一步,如果有图形界面则切换到字符界面 sudo init 3 第二步,切换到root用户,普通用户下无法生成配置文件 sudo su #切换到root 第三步,生成配置文件 Xorg -configure
生成的配置文件会在/root/下找到,文件名为xorg.conf.new。
将xorg.conf.new更改为xorg.conf并复制文件到/etc/X11/下。
mv xorg.conf.new xorg.conf cp xorg.conf /etc/X11/
`/etc/X11/`目录下包含了许多配置文件,用于设置X11图形环境。以下是一些常见的文件:
/etc/X11/xorg.conf: X11的配置文件,用于设置显示器、鼠标、键盘等设备。 /etc/X11/xinit/xinitrc: X11的启动脚本,用于启动X11会话。 /etc/X11/app-defaults/: X11应用程序的默认配置文件夹,用于设置应用程序的默认属性。 /etc/X11/fontpath.d/: X11字体路径配置文件夹,用于设置字体路径。 /etc/X11/fonts.d/: X11字体配置文件夹,用于设置字体信息。 /etc/X11/mimetype/: X11 MIME类型配置文件夹,用于设置文件类型关联。 /etc/X11/xkb/: X11键盘布局配置文件夹,用于设置键盘布局。 /etc/X11/xsession.d/: X11会话配置文件夹,用于设置会话配置。
这些配置文件用于设置X11图形环境的各种参数,包括设备、应用程序、字体、键盘布局等。
Xorg.conf分析
这个是用来测试的xorg.conf文件
Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
# Screen 1 "Screen1" RightOf "Screen0"
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection
Section "Files"//主要配置模块路径和样式路径
ModulePath "/usr/lib/xorg/modules"
FontPath "/usr/share/fonts/X11/misc"
FontPath "/usr/share/fonts/X11/cyrillic"
FontPath "/usr/share/fonts/X11/100dpi/:unscaled"
FontPath "/usr/share/fonts/X11/75dpi/:unscaled"
FontPath "/usr/share/fonts/X11/Type1"
FontPath "/usr/share/fonts/X11/100dpi"
FontPath "/usr/share/fonts/X11/75dpi"
FontPath "built-ins"
EndSection
Section "Module"
Load "glx"//加载glx模块
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"//键盘驱动
EndSection
Section "InputDevice"//输入设备
Identifier "Mouse0"
Driver "mouse"//设备驱动
Option "Protocol" "auto"
Option "Device" "/dev/input/mice"
Option "ZAxisMapping" "4 5 6 7"
EndSection
Section "Monitor"
Identifier "Monitor0"//可自定义名字就是显示屏名字
VendorName "Monitor Vendor"//可自定义
ModelName "Monitor Model"//可自定义
Option "Rotate" "right" //向右旋转90度
EndSection
Section "Device"
#Option "Accel" # [<bool>]
#Option "AccelMethod" # <str>
#Option "Backlight" # <str>
#Option "CustomEDID" # <str>
#Option "DRI" # <str>
#Option "Present" # [<bool>]
#Option "ColorKey" # <i>
#Option "VideoKey" # <i>
#Option "Tiling" # [<bool>]
#Option "LinearFramebuffer" # [<bool>]
#Option "HWRotation" # [<bool>]
#Option "VSync" # [<bool>]
#Option "PageFlip" # [<bool>]
#Option "SwapbuffersWait" # [<bool>]
#Option "TripleBuffer" # [<bool>]
#Option "XvPreferOverlay" # [<bool>]
#Option "HotPlug" # [<bool>]
#Option "ReprobeOutputs" # [<bool>]
#Option "XvMC" # [<bool>]
#Option "ZaphodHeads" # <str>
#Option "VirtualHeads" # <i>
#Option "TearFree" # [<bool>]
#Option "PerCrtcPixmaps" # [<bool>]
#Option "FallbackDebug" # [<bool>]
#Option "DebugFlushBatches" # [<bool>]
#Option "DebugFlushCaches" # [<bool>]
#Option "DebugWait" # [<bool>]
#Option "BufferCache" # [<bool>]
Identifier "Card0"//命名
Driver "intel" //Intel驱动,显示器驱动可以通过
BusID "PCI:0:2:0"//BUS DEV FUN
EndSection
Section "Screen"
Identifier "Screen0"
Device "Card0"//要跟所选择的显示器名称对应的驱动对应
Monitor "Monitor0"//要跟Section "Monitor0"对应
DefaultDepth 24//默认深度
SubSection "Display"
Viewport 0 0
Depth 24 //颜色深度为24
Modes "640x480"//输出分辨率为640x480
EndSubSection
EndSection
- Files: 这是配置文件的部分,加载时可以找到对应的模块和样式文件路径。
- FontPath :设置样式路径。
- ModulePath:设置可加载的 Xorg 服务器模块的搜索路径。
- ServerFlags: 这部分允许设置X服务器的不同标志和选项,如启用或禁用某些功能。
severflags部分选项如下,配置要看日志是否成功启用,不成功就删除对应选项。 Option "BlankTime" "time" //设置屏幕保护程序空白阶段的非活动超时时间以分钟为单位,这相当于 Xorg 服务器的 -s 标志,可以在运行时使用 xset 更改该值,默认值10分钟。 Option "StandbyTime" "time" //设置DPMS模式待机阶段的非活动超时。可以在运行时使用 xset更改该值。 默认值:10 分钟。这仅适用于 VESA DPMS 兼容的显示器,并且可能不受所有视频驱动程序的支持。 Option "SuspendTime" "time" //设置DPMS模式挂起阶段的非活动超时。可以在运行时使用 xset更改该值。默认值:10分钟。这仅适用于VESA DPMS兼容的显示器,并且可能不受所有视频驱动程序的支持。 Option "OffTime" "time" //设置DPMS模式关闭阶段的非活动超时。可以在运行时使用 xset更改该值。默认值:10分钟.这仅适用于VESA DPMS兼容的显示器,并且可能不受所有视频驱动程序的支持。 Option "Xinerama" "boolean" //启用或禁用 XINERAMA 扩展。 默认值为禁用。 Option "AutoBindGPU" "boolean" //如果启用,则辅助 GPU 将自动设置为 output-sinks 和 offload-sources。例如连接笔记本电脑输出 仅供辅助 GPU 直接使用,无需 运行“xrandr --setProviderOutputSource”。 Option "Log" "string" //此选项控制是否刷新日志和/或同步到磁盘 在每条消息之后。可能的值为 flush 或 sync
- Module: 这部分涉及到动态加载模块,可以扩展X服务器的功能。例如,加载特定的驱动程序或插件。
- InputDevice: 这部分描述了连接到计算机的输入设备,如键盘、鼠标或触摸屏。它包括设备名称、驱动程序和其他选项。
- Device: 这部分描述了图形设备(显卡或集成显卡)的特性和配置选项。
Option "Accel" # [<bool>] Option "AccelMethod" # <str> Option "Backlight" # <str> Option "CustomEDID" # <str> Option "DRI" # <str> Option "Present" # [<bool>] Option "ColorKey" # <i> Option "VideoKey" # <i> Option "Tiling" # [<bool>] Option "LinearFramebuffer" # [<bool>] Option "HWRotation" # [<bool>] Option "VSync" # [<bool>] Option "PageFlip" # [<bool>] Option "SwapbuffersWait" # [<bool>] Option "TripleBuffer" # [<bool>] Option "XvPreferOverlay" # [<bool>] Option "HotPlug" # [<bool>] Option "ReprobeOutputs" # [<bool>] Option "XvMC" # [<bool>] Option "ZaphodHeads" # <str> Option "VirtualHeads" # <i> Option "TearFree" # [<bool>] Option "PerCrtcPixmaps" # [<bool>] Option "FallbackDebug" # [<bool>] Option "DebugFlushBatches" # [<bool>] Option "DebugFlushCaches" # [<bool>] Option "DebugWait" # [<bool>] Option "BufferCache" # [<bool>] "Accel": 当设置为True时,启用硬件加速;当设置为False时,禁用硬件加速。 "AccelMethod": 指定加速方法,例如 "uxa"(Unified Acceleration Architecture)或 "sna"(Sandybridge's New Acceleration)。 "Backlight": 指定背光控制方式,可以指定为 "acpi" 或 "raw" 等。 "CustomEDID": 指定自定义扩展显示标识信息数据,用于定制显示器的EDID信息。 "DRI": 指定 Direct Rendering Infrastructure(直接渲染基础设施)的设置,包括启用/禁用和特定的配置参数。 "Present": 当设置为True时,启用显示呈现;当设置为False时,禁用显示呈现。 "ColorKey": 指定颜色关键值,用于图像合成和透明效果。 "VideoKey": 指定视频关键值,用于视频合成和透明效果。 "Tiling": 当设置为True时,启用平铺(Tiling)以提高性能;当设置为False时,禁用平铺。 "LinearFramebuffer": 当设置为True时,使用线性帧缓冲区;当设置为False时,使用其他类型的帧缓冲区。 "HWRotation": 当设置为True时,启用硬件旋转;当设置为False时,禁用硬件旋转。 "VSync": 当设置为True时,启用垂直同步;当设置为False时,禁用垂直同步。 "PageFlip": 当设置为True时,启用页面翻转;当设置为False时,禁用页面翻转。 "SwapbuffersWait": 当设置为True时,等待交换缓冲区;当设置为False时,不等待交换缓冲区。 "TripleBuffer": 当设置为True时,启用三重缓冲;当设置为False时,禁用三重缓冲。 "XvPreferOverlay": 当设置为True时,优先使用叠加(Overlay);当设置为False时,不优先使用叠加。 "HotPlug": 当设置为True时,启用热插拔功能;当设置为False时,禁用热插拔功能。 "ReprobeOutputs": 当设置为True时,重新探测输出;当设置为False时,不重新探测输出。 "XvMC": 当设置为True时,启用XvMC(X-Video Motion Compensation);当设置为False时,禁用XvMC。 "ZaphodHeads": 指定分屏显示的头部,用于多显示器配置。 "VirtualHeads": 指定虚拟显示头的数量,用于虚拟显示配置。 "TearFree": 当设置为True时,启用屏幕撕裂修复;当设置为False时,禁用屏幕撕裂修复。 "PerCrtcPixmaps": 当设置为True时,启用每个CRTC(Cathode Ray Tube Controller)的像素映射;当设置为False时,禁用像素映射。 "FallbackDebug": 当设置为True时,启用回退调试;当设置为False时,禁用回退调试。 "DebugFlushBatches": 当设置为True时,启用批处理调试刷新;当设置为False时,禁用批处理调试刷新。 "DebugFlushCaches": 当设置为True时,启用缓存调试刷新;当设置为False时,禁用缓存调试刷新。 "DebugWait": 当设置为True时,启用调试等待;当设置为False时,禁用调试等待。 "BufferCache": 当设置为True时,启用缓存;当设置为False时,禁用缓存。
- Monitor: 这部分描述了连接到计算机的显示器的特性和配置选项。包括分辨率、刷新率。
VendorName "vendor" //厂商名字 ModelName "model" //型号 HorizSync horizsync-range //水平刷新率 VertRefresh vertrefresh-range //垂直刷新率 DisplaySize width height //显示的宽度和高度 ModeLine //MODELINE用于指定特定的视频模式,包括分辨率、刷新率、颜色深度等参数,可以被多个屏幕(如果使用多个显示器)或多个布局(如果使用不同的布局)使用。 Option "DPMS" "bool" //此选项控制服务器是否应启用DPMS扩展用于此屏幕的电源管理。默认设置是启用外延。 Option "Primary" "bool" //设置为主屏幕,有些Xorg高版本无法使用 Option "PreferredMode" "name" //这个也可以设置分辨率,不同的xorg的版本可能这个参数无法使用 Option "ZoomModes" "namename..." //指定缩放模式 Option "Position" "x y" //代表位置坐标 Option "LeftOf" "output" //表示在另一个显示屏左边 Option "RightOf" "output" //表示在另一个显示屏右边 Option "Above" "output"//指定显示位于另一显示上方 Option "Below" "output"//指定显示位于另一显示下方 Option "Enable" "bool"//表示是否启用该显示屏 Option "MinClock" "frequency"//最小时钟频率 Option "MaxClock" "frequency"//最大时钟频率 Option "Rotate" "rotation" //旋转方向 rotation可以变成right、left...,具体可以通过xrandr -rotate 查看有哪些 注意:有些参数在高版本的xorg下是无法使用的,ubuntu20、22在默认配置下绝大部分参数配置后无法使用。
- Modes: 这部分定义了计算机显示器支持的不同分辨率、刷新率和色彩深度等模式。
- Screen: 这部分定义了屏幕的配置,包括显示器、分辨率、刷新率等。
- ServerLayout: 这部分定义了整个X服务器的布局,包括多个屏幕和输入设备的组合。
- Depth: 颜色深度。
欧拉系统永久配置多屏幕显示的xorg.conf文件如下:
Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection
Section "Files"
ModulePath "/usr/lib64/xorg/modules"
FontPath "catalogue:/etc/X11/fontpath.d"
FontPath "built-ins"
EndSection
Section "Module"
Load "glx"
Load "vnc"
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
EndSection
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/input/mice"
Option "ZAxisMapping" "4 5 6 7"
EndSection
Section "Monitor"
Identifier "VGA-1"
VendorName "Monitor Vendor"
ModelName "Monitor Model"
Modeline "640x480_vga" 31.50 640 656 720 840 480 481 484 500 -hsync -vsync
Option "Primary" "true"
# Option "TearFree" "true"
# Option "VSync" "true"
EndSection
Section "Monitor"
Identifier "eDP-1"
VendorName "Monitor evoc"
ModelName "Monitor evoc-1"
Modeline "640x480_edp" 31.50 640 656 720 840 480 481 484 500 -hsync -vsync
Option "RightOf" "VGA-1"
# Option "TearFree" "true"
# Option "VSync" "true"
EndSection
Section "Device"
Identifier "Card0"
Driver "modesetting"
#Driver "intel"
BusID "PCI:0:2:0"
EndSection
Section "Device"
Identifier "Card1"
Driver "modesetting"
#Driver "intel"
BusID "PCI:0:2:0"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "VGA-1"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "640x480_vga"
EndSubSection
EndSection
Section "Screen"
Identifier "Screen1"
Device "Card1"
Monitor "eDP1"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "640x480_edp"
EndSubSection
EndSection
注意:
配置好后,通过切换字符界面和图形界面来启用,启用时可以通过查看/var/log/Xorg.0.log日志文件进行查看,每一项配置都会日志文件中列出,是否成功使用也可以从中找出。
参考: