在 CentOS 上配置 Compton(现在多称为 picom) 主要用于实现窗口透明、阴影、淡入淡出等合成特效。下面按 CentOS 7 / 8 / Stream 的常见情况说明。
Compton 是 X11 下的合成器,不适用于 Wayland。
echo $XDG_SESSION_TYPE
x11 ✅ 可以继续wayland ❌ 需要切换会话CentOS 7 默认仓库没有 compton,需要 EPEL + 编译安装。
sudo yum install -y epel-release
sudo yum groupinstall -y "Development Tools"
sudo yum install -y \
libX11-devel libXcomposite-devel libXdamage-devel \
libXrandr-devel libXrender-devel libconfig-devel \
dbus-devel mesa-libGL-devel pcre-devel
git clone https://github.com/chjj/compton.git
cd compton
make
sudo make install
推荐使用 picom(compton 的继任者)
sudo dnf install -y epel-release
sudo dnf install -y picom
sudo dnf install -y git meson ninja-build gcc \
libX11-devel libXcomposite-devel libXdamage-devel \
libXrandr-devel libXrender-devel libconfig-devel \
dbus-devel mesa-libGL-devel pcre-devel
git clone https://github.com/yshui/picom.git
cd picom
meson setup build
ninja -C build
sudo ninja -C build install
mkdir -p ~/.config/compton
vim ~/.config/compton/compton.conf
# 开启阴影
shadow = true;
shadow-radius = 12;
shadow-offset-x = -15;
shadow-offset-y = -15;
shadow-opacity = 0.5;
# 透明度
opacity-rule = [
"80:class_g = 'URxvt'",
"90:class_g = 'Alacritty'"
];
# 淡入淡出
fading = true;
fade-in-step = 0.03;
fade-out-step = 0.03;
# 避免全屏撕裂
vsync = true;
# 后端
backend = "glx";
# 排除某些窗口
unredir-if-possible = true;
compton --config ~/.config/compton/compton.conf &
或(picom):
picom --config ~/.config/compton/compton.conf &
在 ~/.i3/config 中加:
exec --no-startup-id compton --config ~/.config/compton/compton.conf
在 ~/.config/openbox/autostart 中加:
compton --config ~/.config/compton/compton.conf &
xfce4-session-settings
→ 应用程序自启动 → 添加 compton
picom 而不是旧版 comptonvsync = true;
backend = "glx";
| 项目 | Compton | Picom |
|---|---|---|
| 维护状态 | ❌ 停止 | ✅ 活跃 |
| 推荐 | 旧系统 | ✅ 新系统 |
| 性能 | 一般 | 更好 |
如果你愿意,可以告诉我:
我可以给你 完全定制的配置方案 ✅