Ubuntu 上 Compton 不生效的排查与修复
一 快速确认与定位
ps -e | grep compton;前台启动:compton -f。前台运行能直接看到报错与警告信息。journalctl -xe | grep compton 查看系统日志;若配置了日志文件,检查如 /var/log/compton.log。which compton 确认路径;compton -V 查看版本,避免调用到错误或过旧二进制。compton --config ~/.config/compton.conf(或你的实际配置路径),如有语法或参数错误会在此步直接提示。二 常见根因与对应修复
compton --config <你的配置> 验证。glx 与 xrender 之间切换),并更新显卡驱动;部分硬件/驱动组合下,特定后端更稳定。/usr/bin/compton)并指定正确配置。三 最小可用配置与验证
nano ~/.config/compton.conf,写入最小可用配置(仅启用阴影与 vsync,便于快速验证):backend = "glx";
vsync = true;
shadow = true;
killall compton,再执行 compton --config ~/.config/compton.conf -f。若阴影、透明度等效果出现,说明 Compton 已生效。compton --config ~/.config/compton.conf &。[Unit]
Description=Compton Window Composer
After=xorg.service
[Service]
ExecStart=/usr/bin/compton --config /etc/xdg/compton.conf
Restart=on-failure
[Install]
WantedBy=multi-user.target
然后执行:sudo systemctl daemon-reload && sudo systemctl enable --now compton,用 systemctl status compton 检查运行状态。
四 仍未生效时的进阶处理
backend(如从 glx 改为 xrender 或反之),重启 Compton 测试效果与稳定性。sudo apt-get update && sudo apt-get upgrade,确保图形栈与依赖为最新稳定版本。sudo apt-get remove --purge compton && sudo apt-get install compton,修复可能的安装损坏或缺失依赖。journalctl -xe | grep compton 与配置文件路径、权限、命令参数是否一致,必要时提高日志输出级别进行排查。