CentOS 下 Compton 配置要点
一 安装与运行环境
二 配置文件与关键参数
backend = "glx";
vsync = true;
shadow = false;
inactive-opacity = 0.9;
active-opacity = 1.0;
ignore_root = true;
fps-limit = 60;
unredir-if-possible = true;
# 可选:按应用排除阴影/透明度
shadow-exclude = ["class_g = 'Firefox'", "class_g = 'Conky'"];
opacity-rule = ["90:class_g = 'Alacritty'", "100:class_g = 'Firefox'"];
# 可选:背景模糊(性能代价更高)
# blur-background = true;
# blur-method = "kawase"; # 或 "gaussian"
# blur-strength = 5;
三 自启动与系统集成
compton -c ~/.config/compton.conf(便于看日志与报错)compton -b -c ~/.config/compton.conf# /etc/systemd/system/compton.service
[Unit]
Description=Compton Window Compositor
After=graphical.target
[Service]
Type=exec
ExecStart=/usr/bin/compton -b -c /home/你的用户名/.config/compton.conf
Restart=on-failure
Environment=XDG_RUNTIME_DIR=/run/user/%U
[Install]
WantedBy=default.target
systemctl --user daemon-reload && systemctl --user enable --now compton# /etc/systemd/system/compton.service
[Unit]
Description=Compton Window Compositor
After=display-manager.service
[Service]
ExecStart=/usr/bin/compton -b -c /etc/compton.conf
Restart=on-failure
[Install]
WantedBy=multi-user.target
systemctl daemon-reload && systemctl enable --now compton四 调试与常见问题处理
ps -e | grep comptoncompton --log-level debug --log-file /tmp/compton.log,或 journalctl -u compton -xebackend = "glx"),逐步恢复;确认配置文件路径与权限。vsync = true;若仍撕裂,尝试 backend = "xrender" 或更换驱动/内核参数。fps-limit;减少 opacity-rule 数量;必要时改用 xrender。shadow-exclude 是否误伤目标窗口(如通知、Dock、Conky)。ldd $(which compton) 检查缺失库;ldconfig -p 查看缓存;必要时安装开发库或从源码编译。五 性能优化与替代方案
shadow = false,blur-background = falsefps-limit = 60(笔记本可降至 30–45)unredir-if-possible = true,必要时为特定应用添加例外update-interval = 0.1(视硬件与桌面而定)top/htop 观察 compton 占用,配合日志定位瓶颈