温馨提示×

centos中compton咋配置

小樊
42
2026-10-17 21:41:43
栏目: 智能运维

在 CentOS 里使用 compton(现在社区多叫 picom,compton 已停止维护)主要用来做窗口合成(透明、阴影、模糊等)。下面按 安装 → 配置 → 启动 → 自启 给你一套实用说明。


一、安装 compton / picom

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

二、配置文件位置

推荐放在用户目录:

~/.config/compton.conf

如果没有就新建:

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

三、常用配置示例(compton.conf)

1️⃣ 基础透明 + 阴影

backend = "glx";
shadow = true;
shadow-radius = 10;
shadow-opacity = 0.5;
shadow-offset-x = -5;
shadow-offset-y = -5;

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

2️⃣ 窗口淡入淡出

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

3️⃣ 避免全屏卡顿(游戏/视频)

unredir-if-possible = true;

4️⃣ 忽略某些窗口阴影

shadow-exclude = [
  "name = 'Notification'",
  "class_g = 'Conky'"
];

四、启动 compton

手动启动

compton --config ~/.config/compton.conf -b

-b 表示后台运行

检查是否运行

ps aux | grep compton

五、开机自启(不同桌面环境)

1️⃣ 通用(~/.xinitrc)

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

2️⃣ GNOME / KDE

  • 设置 → 开机启动
  • 添加命令:
compton --config ~/.config/compton.conf

3️⃣ i3 / bspwm(推荐)

在 ~/.config/i3/config:

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

六、常见问题

❌ 透明无效

  • 确保窗口管理器支持 compositing
  • 使用 backend = "glx" 或 xrender

❌ CPU 占用高

backend = "xrender";
vsync = false;

❌ 黑屏 / 闪屏

glx-swap-method = "exchange";

七、compton vs picom

项目 compton picom
维护状态 ❌ 停更 ✅ 活跃
模糊支持 弱 强
推荐 老系统 新系统

picom 配置基本兼容 compton。


如果你告诉我:

  • CentOS 版本
  • 桌面环境(GNOME / KDE / i3 / 无桌面)

我可以给你 针对性配置。

0 踩