在 CentOS 上定制 Compton 的思路与步骤
安装与配置文件准备
sudo yum install comptonsudo dnf install comptonmkdir -p ~/.config && nano ~/.config/compton.confkillall compton && compton --config ~/.config/compton.conf &~/.xprofile 或 ~/.xinitrc:compton --config ~/.config/compton.conf &/etc/compton.conf。核心配置项与推荐值
backend = "glx"(或尝试 "egl";性能不佳时再试 "xrender")vsync = true(减少撕裂;若输入延迟高或卡顿,改为 false 测试)shadow = trueshadow-radius = 4、shadow-offset-x = 2、shadow-offset-y = 2、shadow-opacity = 0.3shadow-exclude = [ "class_g = 'gnome-terminal'", "class_g = 'konsole'" ]fade = true、fade-delta = 10glx-no-stencil = trueglx-copy-from-front = trueglx-damage = trueunredir-if-possible = trueopacity = 0.95blur-background = true、blur-method = "gaussian"、blur-size = 10、blur-deviation = 5.0ignore-root = falseframe-rate = 60(或设为显示器刷新率,如 120/144)按场景给出可直接使用的配置示例
backend = "glx"vsync = trueshadow = falseblur-background = falsefade = trueunredir-if-possible = trueglx-no-stencil = true; glx-copy-from-front = true; glx-damage = truebackend = "glx"vsync = trueshadow = true; shadow-radius = 6; shadow-offset-x = 2; shadow-offset-y = 2; shadow-opacity = 0.35blur-background = true; blur-method = "gaussian"; blur-size = 12; blur-deviation = 6.0fade = truebackend = "glx"vsync = false(或按显示器能力选择)unredir-if-possible = trueshadow = falseblur-background = falsefade = falseglx-damage = true开机自启与常见问题处理
/etc/systemd/user/compton.service[Unit]
Description=Compton CompositorAfter=graphical-session.target[Service]
Type=simpleExecStart=/usr/bin/compton --config %h/.config/compton.conf --replaceRestart=on-failure[Install]
WantedBy=graphical-session.targetsystemctl --user daemon-reloadsystemctl --user enable --now comptonAfter=display-manager.service 并放置于 /etc/systemd/system/compton.service,然后用 sudo systemctl enable --now compton 管理。backend(glx/egl/xrender)、切换 vsync(true/false)、关闭 shadow/blur/fade 测试。unredir-if-possible = true,并关闭阴影/模糊。cpulimit -l 50 -p $(pgrep compton)(将占用限制在约 50%)。