温馨提示×

怎样在centos配compton

小樊
46
2026-10-12 02:40:15
栏目: 智能运维

在 CentOS 上配置 compton(现在多称为 picom 的前身)一般用于给窗口管理器(如 i3、Openbox、awesome 等)提供透明、阴影、模糊等合成效果。下面按步骤说明。


一、安装 Compton

1. 启用 EPEL 源(CentOS 7)

sudo yum install -y epel-release

2. 安装 compton

CentOS 7

sudo yum install -y compton

CentOS 8 / Stream

sudo dnf install -y compton

如果仓库没有,可使用 picom(compton 的活跃分支):

sudo dnf install -y picom

二、创建配置文件

配置文件通常位于:

~/.config/compton.conf

示例配置(常用):

backend = "glx";
glx-no-stencil = true;

shadow = true;
shadow-radius = 8;
shadow-opacity = 0.4;
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;

vsync = "opengl";

unredir-if-possible = true;

三、启动 Compton

手动启动

compton --config ~/.config/compton.conf &

开机自启(以 i3 为例)

在 ~/.config/i3/config 中加入:

exec --no-startup-id compton --config ~/.config/compton.conf

四、常见问题

1. 黑屏或闪烁

尝试切换 backend:

backend = "xrender";

2. NVIDIA 显卡

建议使用:

backend = "glx";
glx-no-stencil = true;
vsync = "none";

3. CentOS 无 compton 包

可手动编译:

sudo yum install -y git meson ninja-build libconfig-devel dbus-devel xcb-devel
git clone https://github.com/yshui/picom.git
cd picom
meson setup build
ninja -C build
sudo ninja -C build install

五、验证是否运行

ps aux | grep compton

如果你使用的是 具体窗口管理器(i3 / Openbox / awesome) 或 CentOS 版本,可以告诉我,我可以给你更精确的配置。

0 踩