在 CentOS 上“配不好 compton”是很多人都会踩坑的问题,通常不是你配置写错,而是环境本身和 compton 的假设不一致。下面把常见原因和解决办法一次性说清楚。
一、CentOS 上 compton 最常见的几个坑
1️⃣ 默认用的是 GNOME + Mutter,根本不需要 compton
- CentOS 桌面版默认是 GNOME
- GNOME 自己有合成器(mutter)
- 再跑 compton:
- 要么没效果
- 要么直接闪屏 / 黑屏 / 卡死
✅ 正确情况:
- compton 只适合 轻量窗口管理器
- i3 / bspwm / openbox / fluxbox
- 如果你在 GNOME 里硬跑 compton,基本必翻车
2️⃣ CentOS 7 太老,compton 依赖不对
CentOS 7:
- GLib / X11 / libconfig 版本旧
- 官方源 没有 compton
- 自己编译经常报:
undefined referenceXComposite not found
✅ 建议:
- CentOS 7 → 用
xcompmgr(能用但弱) - 或升级到 CentOS 8 / Stream / Rocky / Alma
3️⃣ 你用的是 Wayland,不是 X11
CentOS 8+ GNOME 默认 Wayland
- compton 只支持 X11
- Wayland 下 compton 直接不工作
检查方式:
echo $XDG_SESSION_TYPE
wayland→ compton 不可能好使x11→ 才有可能
✅ 解决:
- 登录界面选 “GNOME on Xorg”
4️⃣ 没有正确后端(OpenGL / XRender)
compton 需要:
libGLlibXrender- 有时还要
mesa-dri-drivers
缺少时表现:
- 启动瞬间退出
- 透明无效
- CPU 占用爆高
安装:
yum install mesa-libGL mesa-dri-drivers libXrender libconfig
5️⃣ 配置文件路径 / 格式错误
compton 默认读:
~/.config/compton.conf
常见错误:
- 用
.conf写成了compton.config - YAML 缩进错误
- 混用了旧参数名
最小可用配置示例:
backend = "glx";
glx-no-stencil = true;
shadow = true;
fade = true;
二、CentOS 上“正确姿势”总结
✅ 正确组合(能稳定用 compton)
- CentOS 8 / Stream
- X11 会话
- i3 / openbox
- compton 从 EPEL 或自己编译
❌ 错误组合(怎么都配不好)
- CentOS 7 + GNOME
- Wayland + compton
- GNOME + compton 当“美化工具”
三、如果你愿意,我可以帮你
你可以直接告诉我:
- CentOS 版本(7 / 8 / Stream?)
- 桌面环境(GNOME / i3 / openbox?)
- 报错信息或现象(闪屏 / 没透明 / 起不来)
我可以给你一套能直接用的配置 + 启动方式,不再试错。