在 CentOS 上配置 compton(一个轻量级 X11 合成管理器,常用于 i3 / openbox 等窗口管理器)大致步骤如下:
一、安装 compton
CentOS 7
sudo yum install epel-release
sudo yum install compton
CentOS 8 / Stream
sudo dnf install epel-release
sudo dnf install compton
如果仓库里没有
compton,可以用picom(compton 的继任者):
sudo dnf install picom
二、创建配置文件
compton 默认读取:
~/.config/compton.conf
创建目录和文件:
mkdir -p ~/.config
touch ~/.config/compton.conf
示例配置(常用)
backend = "glx";
shadow = true;
fade = true;
opacity-rule = [
"90:class_g = 'URxvt'"
];
# 避免全屏卡顿
unredir-if-possible = true;
三、启动 compton
手动启动
compton &
或(使用配置文件):
compton --config ~/.config/compton.conf &
四、开机自动启动
i3 用户
在 ~/.config/i3/config 中添加:
exec --no-startup-id compton
Openbox 用户
在 ~/.config/openbox/autostart 中添加:
compton &
通用方式(systemd 用户会话)
systemctl --user enable compton
(部分 CentOS 版本需手动写 service)
五、常见问题
1. 黑屏 / 无透明
- 确认使用 X11,不是 Wayland
- 显卡驱动正常(尤其是 NVIDIA)
2. NVIDIA 用户
配置中加:
backend = "xrender";
3. 高 CPU 占用
关闭阴影或 fade:
shadow = false;
fade = false;
六、compton vs picom
| 项目 | compton | picom |
|---|---|---|
| 维护状态 | 停止 | 活跃 |
| 推荐度 | 旧系统 | 新系统 |
如果你告诉我:
- CentOS 版本
- 桌面环境(i3 / openbox / 无)
- 显卡型号
我可以给你更精确的配置。