温馨提示×

centos compton如何调配置

小樊
45
2026-10-23 20:18:33
栏目: 智能运维

在 CentOS 上,Compton(现在更多是 picom 的前身)是一个常用的 X11 合成管理器,用来实现窗口透明、阴影、模糊等效果。下面从安装 → 配置文件 → 常用调参 → 常见问题给你讲清楚。


一、安装 Compton

CentOS 7

sudo yum install epel-release
sudo yum install compton

CentOS 8 / Stream

sudo dnf install epel-release
sudo dnf install compton

如果仓库里没有,也可以装 picom(更现代):

sudo dnf install picom

二、配置文件位置

Compton 默认读取:

~/.config/compton.conf

如果不存在,可以新建:

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

三、基础配置示例(常用)

下面是一个常见且稳定的配置:

# 后台运行
backend = "xrender";

# 窗口阴影
shadow = true;
shadow-radius = 12;
shadow-opacity = 0.5;
shadow-offset-x = -5;
shadow-offset-y = -5;

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

# 淡入淡出
fade = true;
fade-in-step = 0.03;
fade-out-step = 0.03;

# 不透明化当前窗口
inactive-opacity = 0.9;

# 排除某些程序
shadow-exclude = [
  "class_g = 'Dmenu'",
  "class_g = 'Notify-osd'"
];

# 刷新率
vsync = true;

四、启动 Compton

手动启动

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

开机自启(i3 / Openbox 等)

在 ~/.xinitrc 或 WM 配置里加:

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

五、常用调参说明

1️⃣ 阴影(最常用)

shadow = true
shadow-radius = 15
shadow-opacity = 0.75

2️⃣ 窗口透明

inactive-opacity = 0.85
active-opacity = 1.0

3️⃣ 模糊(需要 GLX backend)

backend = "glx";
blur-method = "gaussian";
blur-strength = 10;

4️⃣ 避免终端卡顿

unredir-if-possible = true;

六、常见问题

❌ 透明无效

  • 确认桌面环境 不是 GNOME(默认用 Mutter)
  • Compton 只适用于 i3 / Openbox / Fluxbox / Awesome

❌ 黑屏 / 卡死

  • 换 backend:
backend = "xrender";

❌ CPU 占用高

  • 关掉 blur
  • 降低 shadow-radius

七、Compton vs Picom

项目 Compton Picom
维护状态 停止 活跃
模糊 弱 强
推荐 ❌ ✅

建议新系统直接用 picom:

picom --config ~/.config/picom.conf

如果你愿意,可以告诉我:

  • 你用的是 哪个桌面环境 / 窗口管理器
  • 想要 透明 / 模糊 / 阴影 / 性能优先

我可以直接帮你写一份可用配置。

0 踩