温馨提示×

compton centos配置啥步骤

小樊
35
2026-10-26 18:48:07
栏目: 智能运维

你提到的 “Compton” 在 CentOS 上通常是指 Compton 合成器(窗口阴影/透明效果),常用于 i3 / Openbox 等轻量桌面环境。下面给你一份CentOS 上配置 Compton 的常见步骤(以 CentOS 7/8 为例,CentOS Stream 也基本通用)。


一、安装 Compton

1. 启用 EPEL 源(CentOS 7/8)

sudo yum install epel-release -y
# CentOS 8 / Stream
sudo dnf install epel-release -y

2. 安装 Compton

sudo yum install compton -y
# 或
sudo dnf install compton -y

⚠️ 注意:

  • CentOS 8 之后部分版本仓库里叫 picom(Compton 的 fork)
  • 可尝试:
sudo dnf install picom

二、创建 Compton 配置文件

mkdir -p ~/.config/compton
vi ~/.config/compton/compton.conf

基础示例配置(适合 i3)

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

shadow = true;
shadow-radius = 8;
shadow-opacity = 0.6;
shadow-offset-x = -4;
shadow-offset-y = -4;

opacity-rule = [
  "90:class_g = 'URxvt'",
  "95:class_g = 'Firefox'"
];

fade = true;
fade-in-step = 0.03;
fade-out-step = 0.03;

vsync = "opengl-swc";

三、启动 Compton

手动测试

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

如果没报错,说明配置可用。


四、开机自动启动(以 i3 为例)

编辑 ~/.config/i3/config:

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

如果是 Openbox:

vi ~/.config/openbox/autostart

添加:

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

五、常见问题排查

1. 黑屏 / 卡顿

尝试修改 backend:

backend = "xrender";

2. NVIDIA 显卡

建议:

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

3. 没有透明效果

  • 确保窗口管理器支持 RGBA
  • 终端需支持透明(如 urxvt / alacritty)

六、Compton 已停止维护说明

现在更推荐:

sudo dnf install picom

配置文件路径相同,命令用 picom 替代 compton


如果你说的是 “Compton 在 CentOS 上做别的事”(比如某服务、某个软件叫 Compton),可以告诉我具体场景,我给你更针对性的步骤。

0 踩