CentOS 下 Compton 配置失败的定位与修复
一 快速定位问题
chmod 644 ~/.config/compton.conf)。killall compton),再以调试模式前台运行并输出到日志,便于直接看到报错。示例:compton --config ~/.config/compton.conf --log-level 0 --log-file /tmp/compton.log &。compton --config /path/to/compton.conf校验配置语法;若提示未知/弃用选项(如no-dock-shadow、menu-opacity),按新版语义修正(例如用shadow选项并配合规则控制,如shadow-exclude = ["name = 'Dock'"];)。journalctl -xe | grep compton或查看/var/log/compton.log获取更详细的失败原因。systemctl status compton.service,必要时停止/禁用后再改为手动前台调试,避免被旧服务配置干扰。二 常见原因与对应修复
compton --config校验;将弃用项替换为新版支持的写法(如用shadow与shadow-exclude替代no-dock-shadow)。backend为xrender或glx以匹配显卡与驱动;遇到异常先回退到更稳定的后端。三 最小可用配置示例
# ~/.config/compton.conf
backend = "glx";
vsync = true;
shadow = true;
shadow-radius = 12;
shadow-offset-x = -12;
shadow-offset-y = -12;
shadow-exclude = [
"name = 'Notification'",
"name = 'Dock'",
"class_g = 'Conky'",
"class_g ?= 'Polybar'",
"_GTK_FRAME_EXTENTS@:c"
];
fade-in-step = 0.03;
fade-out-step = 0.03;
inactive-opacity = 0.95;
active-opacity = 1.0;
mark-unsafe-fonts = true;
compton --config ~/.config/compton.conf --log-level 0 --log-file /tmp/compton.log &,确认无报错再设为自启。四 仍未解决时的处理
/tmp/compton.log或journalctl输出)、以及最小复现配置,便于社区定位。