Ubuntu Compton故障排查之日志分析与实用技巧
日志是排查Compton故障的核心依据,以下是常用查看方法:
/.cache/compton/compton.log,可通过以下命令查看内容或最新条目:cat /.cache/compton/compton.log # 查看完整日志
tail -n 50 /.cache/compton/compton.log # 查看最后50行(近期日志)
journalctl命令过滤服务日志:journalctl -u compton.service # 查看所有Compton服务日志
journalctl -u compton.service -n 10 # 查看最近10条日志
journalctl -u compton.service -f # 实时跟踪最新日志(按Ctrl+C退出)
cat /var/log/syslog | grep compton # 从syslog中筛选Compton相关条目
dmesg | grep compton # 检查内核日志中的Compton错误
/.config/compton.conf),添加日志路径和级别:log-file = /path/to/custom.log # 指定自定义日志文件路径
log-level = debug # 设置日志级别(debug/info/warn/error)
修改后重启Compton使配置生效:killall compton && compton &。compton.log或journalctl中是否有“Failed to start”“Cannot connect to X server”“Backend not available”等错误。ps -e | grep compton(若有残留进程,用killall compton终止)。compton --config /dev/null),若正常则原配置有误;或通过picom --log-level DEBUG生成调试日志。libxext-dev libxcb1-dev等必要库(sudo apt install libxext-dev libxcb1-dev)。compton.log中是否有“VSync failed”“High CPU usage”“GLX error”等提示。glx后端卡顿,尝试改为xrender(backend = "xrender");若NVIDIA显卡,添加glx-use-copysubbuffermesa = true。shadow = false)、模糊(blur = false)等耗性能的配置。vsync = false或调整frame-rate(如frame-rate = 30)。compton.log中是否有“Invalid opacity rule”“Failed to apply transparency”“VSync mismatch”等错误。opacity-rule格式(如opacity-rule = ["85:class_g = 'Alacritty'"]),避免拼写错误。shadow-exclude或opacity-exclude排除通知中心、Conky等不需要效果的窗口(如shadow-exclude = ["name = 'Notification'"])。vsync-type = "drm"或vsync = false)。journalctl中是否有“Conflict with GNOME/KDE compositor”“Xorg errors”等提示。gsettings set org.gnome.mutter overlay-key '')。top或htop查看系统资源占用,结束占用过高的进程。compton --config /dev/null启动Compton,若正常则问题出在自定义配置文件中,逐步添加配置项定位故障点。picom --log-level DEBUG --log-file ~/picom.log生成详细日志,结合tail -f ~/picom.log实时查看运行状态。sudo apt update && sudo apt upgrade compton);若问题出现在更新后,可回滚到旧版本(sudo apt install compton=<旧版本号>)。compton --version);compton.log或journalctl输出);/.config/compton.conf);