在 CentOS 上配置 Compton(或新版 picom) 出现黑屏,通常不是 Compton 本身坏了,而是显示环境 / 配置 / 显卡驱动不匹配。下面按「最常见 → 较少见」帮你排查。
Compton 不能在显示服务器启动前运行
✅ 正确方式:
~/.xinitrc 或 WM 自启动中启动 compton❌ 错误方式:
CentOS 默认环境(尤其虚拟机 / 老显卡)不支持 glx
黑屏典型配置:
backend = "glx";
✅ 解决办法(改 ~/.config/compton.conf):
backend = "xrender";
然后重启:
compton --config ~/.config/compton.conf
如果你只看到黑屏但鼠标能动:
opacity-rule = [ "90:class_g = '.*'" ];
但窗口管理器没正确加载
✅ 检查:
echo $XDG_SESSION_TYPE
x11 ✅wayland ❌(Compton 不支持)Compton 不支持 Wayland
✅ 解决:
sway(不是 compton)CentOS + NVIDIA 常见
✅ 临时测试:
compton --backend xrender --vsync none
❌ 避免:
backend = "glx";
CentOS 上更推荐:
sudo yum install picom
使用:
picom --config ~/.config/picom.conf
~/.config/compton.conf
backend = "xrender";
vsync = false;
shadow = false;
fade = false;
启动:
compton --config ~/.config/compton.conf &
echo $XDG_SESSION_TYPE # 必须是 x11
glxinfo | grep OpenGL # 看是否支持
ps aux | grep compton # 是否在运行
如果你愿意,可以告诉我:
我可以直接给你一份能用的配置。