在 CentOS 上让 Compton 更流畅的实用优化

一 基础准备与驱动
sudo dnf install compton 或 sudo yum install compton。二 核心配置优化
shader-file/shader-frag/shader-vert 置空)以减少开销。xrandr 获取实际刷新率并写入配置,例如:xrandr | grep -oP 'd+.d+Hz' | head -1 得到 60.00,在配置中使用 refresh-rate = 60。backend = "glx"vsync = trueshadow = falseopacity = falsealpha-mode = "none"frame-rate = 60refresh-rate = 60glx-no-stencil = trueglx-copy-from-front = trueshadow-exclude = [ ".*" ]xrandr-args = ""应用方式:killall compton && compton --config ~/.config/compton.conf。三 启动与系统集成
mkdir -p ~/.config/systemd/uservim ~/.config/systemd/user/compton.service[Unit]Description=Compton Window ComposerAfter=graphical-session.target[Service]ExecStart=/usr/bin/compton --config %h/.config/compton.conf --no-daemonRestart=always[Install]WantedBy=default.targetsystemctl --user daemon-reload && systemctl --user enable --now comptonkillall compton && compton --config ~/.config/compton.conf。四 资源控制与故障排查
cpulimit 临时约束,例如 cpulimit -l 50 -p $(pgrep compton)(将 PID 替换为实际进程号)。log-level = 0、log-file = /tmp/compton.log、debug = false,便于定位卡顿来源(如频繁重绘、特效冲突)。