在 CentOS 上配置 Compton(一个轻量级 X11 合成管理器,常用于 i3 / Openbox 等环境),一般步骤如下:
sudo yum install epel-release
sudo yum install compton
sudo dnf install epel-release
sudo dnf install compton
如果仓库里没有,可以用源码编译或从 COPR 安装。
Compton 默认读取:
~/.config/compton.conf
创建目录和文件:
mkdir -p ~/.config
vim ~/.config/compton.conf
# 后端
backend = "glx";
# 开启阴影
shadow = true;
shadow-radius = 8;
shadow-opacity = 0.5;
shadow-offset-x = -2;
shadow-offset-y = -2;
# 透明度
opacity-rule = [
"90:class_g = 'URxvt'",
"95:class_g = 'Firefox'"
];
# 淡入淡出
fading = true;
fade-in-step = 0.03;
fade-out-step = 0.03;
# 不透明窗口检测
detect-rounded-corners = true;
detect-client-opacity = true;
# 排除某些窗口(如全屏)
unredir-if-possible = true;
# GLX 设置
glx-no-stencil = true;
glx-copy-from-front = false;
compton --config ~/.config/compton.conf -b
-b 表示后台运行。
在 ~/.config/i3/config 中加入:
exec --no-startup-id compton --config ~/.config/compton.conf -b
编辑 ~/.config/openbox/autostart:
compton --config ~/.config/compton.conf -b &
尝试切换后端:
backend = "xrender";
建议:
backend = "glx";
glx-no-stencil = true;
并确保安装了专有驱动。
unredir-if-possible = true;
前台运行看日志:
compton --config ~/.config/compton.conf --show-all-errors
如果你用的是 CentOS 具体版本 + 桌面环境(i3 / GNOME / KDE),我可以给你更精确的配置。