Compton本身不直接配置分辨率
Compton是一款窗口合成器(负责窗口特效、透明度和合成),其配置文件(~/.config/compton.conf)主要管理窗口动画、阴影、透明度等视觉效果,不包含分辨率设置选项。分辨率调整需通过系统级的显示工具(如xrandr)完成,以下是具体步骤:
打开终端,运行以下命令查看已连接的显示器名称(如HDMI-1、eDP-1)及支持的分辨率:
xrandr
输出示例:
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 7680 x 4320
HDMI-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 527mm x 296mm
1920x1080 60.00*+ 50.00 59.94
2560x1440 59.96
3840x2160 30.00 25.00
若需要的分辨率未在xrandr输出中列出,可使用cvt命令生成。例如,添加3840x2160@60Hz模式:
cvt 3840 2160 60
输出示例:
# 3840x2160 59.98 Hz (CVT 8.29M9) hsync: 134.18 kHz; pclk: 712.75 MHz
Modeline "3840x2160_60.00" 712.75 3840 4160 4576 5312 2160 2163 2168 2237 -hsync +vsync
将cvt生成的Modeline复制,使用xrandr --newmode创建模式,再用xrandr --addmode添加到显示器:
xrandr --newmode "3840x2160_60.00" 712.75 3840 4160 4576 5312 2160 2163 2168 2237 -hsync +vsync
xrandr --addmode HDMI-1 "3840x2160_60.00"
注:将
HDMI-1替换为你的显示器名称(来自xrandr输出)。
使用xrandr --output命令应用新分辨率:
xrandr --output HDMI-1 --mode "3840x2160_60.00"
若需重启后保持分辨率不变,需修改Xorg配置文件:
停止图形界面(如GDM),生成默认配置:
sudo systemctl stop gdm
sudo Xorg -configure
生成的配置文件通常位于/root/xorg.conf.new,将其复制到/etc/X11/xorg.conf:
sudo mv /root/xorg.conf.new /etc/X11/xorg.conf
打开/etc/X11/xorg.conf,在Section "Monitor"中添加Modeline和PreferredMode,在Section "Screen"中指定默认模式:
Section "Monitor"
Identifier "Configured Monitor"
Modeline "3840x2160_60.00" 712.75 3840 4160 4576 5312 2160 2163 2168 2237 -hsync +vsync
Option "PreferredMode" "3840x2160_60.00"
EndSection
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "3840x2160_60.00" "1920x1080" # 优先使用3840x2160,失败则回退到1080p
EndSubSection
EndSection
注:
Device部分需根据你的显卡型号修改(可通过lspci | grep VGA查看)。
sudo reboot
若使用GNOME、KDE等桌面环境,可通过图形工具快速调整:
xrandr可能无法正常工作。picom(Compton的Wayland分支),但分辨率调整仍依赖系统工具。xorg.conf前建议备份(sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak),避免配置错误导致无法进入桌面。