温馨提示×

linux compton配置怎样调试

小樊
48
2026-09-21 23:34:11
栏目: 智能运维

在 Linux 下调试 compton(或其继任者 picom)配置,通常可以从日志输出、配置校验、进程管理、参数排查几个方面入手。下面按实用顺序说明。


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

很多发行版已用 picom(compton 的 fork):

which compton picom
compton --version
picom --version

以下以 compton 为例,picom 参数基本一致。


二、前台运行并查看日志(最重要)

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

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

或(更详细):

compton -CGb --backend glx --log-level trace --log-file /tmp/compton.log

常用调试参数:

  • -C:只管理客户端窗口
  • -G:禁用阴影(排除阴影问题)
  • -b:后台运行(调试时不要加
  • --backend xrender|glx:切换渲染后端
  • --log-level trace|debug|info

查看日志:

tail -f /tmp/compton.log

三、最小化配置法(排除配置错误)

新建一个最小配置

~/.config/compton.min.conf
backend = "xrender";
shadow = false;
fade = false;

运行:

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

✅ 如果最小配置正常:

  • 说明是原配置某一项导致问题
  • 逐项加回原配置排查

四、常见调试点(非常实用)

1. 黑屏 / 闪屏

尝试:

backend = "xrender";
vsync = false;

或:

compton --backend xrender --vsync none

2. 窗口阴影异常

关闭阴影测试:

shadow = false;

检查 shadow-exclude:

shadow-exclude = [
  "name = 'Notification'"
];

3. 透明失效

确认:

  • 终端支持透明(URxvt / Alacritty / Kitty)
  • 未设置 opacity-rule 错误

测试:

opacity-rule = [
  "90:class_g = 'URxvt'"
];

4. 多显示器问题

指定显示器:

compton --display :0

或限制区域:

shadow-exclude-reg = "x10+0+0";

五、进程与冲突排查

检查是否有多个 compositor

ps aux | grep -E "compton|picom|xcompmgr"

关闭其他:

killall xcompmgr

重新加载配置

compton 不支持热重载,需重启:

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

六、结合 WM / DE 调试

  • i3 / bspwm:手动启动 compton
  • KDE / GNOME:自带 compositor,需关闭
  • Openbox:在 autostart 中加 compton

七、快速自检清单 ✅

  • [ ] 前台运行看日志
  • [ ] 使用最小配置
  • [ ] 切换 xrender / glx
  • [ ] 关闭 vsync / shadow
  • [ ] 确认无其他 compositor
  • [ ] 检查 backend 是否支持

如果你愿意,可以:

  • 贴出 compton.conf
  • 说明 桌面环境 / 窗口管理器
  • 描述具体现象(黑屏、卡顿、透明失效)

我可以直接帮你定位问题。

0