温馨提示×

如何调试ubuntu compton错误

小樊
35
2026-10-21 16:51:17
栏目: 智能运维

在 Ubuntu 上调试 compton(或已更名为 picom) 的报错,通常可以按下面步骤系统排查。


一、确认你用的是 compton 还是 picom

很多 Ubuntu 版本已经用 picom 替代 compton:

which compton
which picom
  • 有 picom → 用 picom
  • 只有 compton → 继续用 compton

下文以 compton 为例,picom 同理。


二、前台运行并查看错误输出(最重要)

不要直接后台启动,先前台运行:

compton --config ~/.config/compton.conf

或:

compton -b --config ~/.config/compton.conf

如果已经后台运行,先杀掉:

pkill compton

观察终端输出,常见错误包括:

  • 配置文件语法错误
  • backend 不支持
  • OpenGL / Xrender 初始化失败

三、使用调试模式

开启详细日志:

compton --show-all-errors --log-level trace

或写入日志文件:

compton --log-file /tmp/compton.log

然后查看:

cat /tmp/compton.log

四、常见错误与解决办法

1️⃣ 配置文件错误

报错类似:

parse error: ...

解决:

  • 检查 ~/.config/compton.conf
  • 用官方示例配置测试:
cp /usr/share/doc/compton/examples/compton.sample.conf ~/.config/compton.conf

或(picom):

cp /usr/share/doc/picom/examples/picom.sample.conf ~/.config/picom.conf

2️⃣ backend 报错(OpenGL / Xrender)

报错:

Failed to initialize backend

尝试指定 backend:

compton --backend xrender

或:

compton --backend glx

在配置文件中:

backend = "xrender";

3️⃣ 缺少依赖

常见缺失:

  • libgl1
  • libxext6
  • libxrender1
  • libconfig9

修复:

sudo apt update
sudo apt install compton libconfig9 libgl1-mesa-dri

4️⃣ 显示器 / 会话问题

如果你在:

  • Wayland
  • 某些桌面环境(GNOME)

compton 可能不工作。

检查会话:

echo $XDG_SESSION_TYPE
  • wayland → compton 不支持
  • x11 → 正常

五、最小可运行配置(测试用)

backend = "xrender";
opacity-rule = [ "90:class_g = 'Firefox'" ];
shadow = false;
fade = false;

六、自动启动调试

如果你用 i3 / Openbox:

exec compton --config ~/.config/compton.conf

调试时改成:

exec compton --config ~/.config/compton.conf --show-all-errors

七、仍无法解决?

请提供以下信息,我可以精准帮你:

  1. Ubuntu 版本
  2. 桌面环境(GNOME / KDE / i3 等)
  3. compton --version
  4. 完整报错信息(终端 / 日志)

这样能更快定位问题。

0 踩