温馨提示×

centos compton启动如何配

小樊
46
2026-10-03 07:45:32
栏目: 智能运维

在 CentOS 上配置并启动 Compton(现在多称为 picom 的分支/前身),通常用于为无独立合成器的窗口管理器(如 i3、Openbox、awesome)提供透明、阴影、模糊等特效。下面按步骤说明。


一、安装 Compton

CentOS 7

sudo yum install epel-release
sudo yum install compton

CentOS 8 / Stream

sudo dnf install epel-release
sudo dnf install compton

如果仓库没有 compton,可以考虑安装 picom(新一代分支):

sudo dnf install picom

(以下配置对两者基本通用,文件名换成 picom.conf 即可)


二、创建配置文件

Compton 默认读取:

~/.config/compton.conf

示例配置(常用、稳定):

# 透明
backend = "glx";
vsync = true;

# 阴影
shadow = true;
shadow-radius = 12;
shadow-offset-x = -2;
shadow-offset-y = -2;
shadow-opacity = 0.5;

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

# 不透明窗口
no-dock-shadow = true;
clear-shadow = true;

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

三、启动 Compton

手动启动

compton &

或(picom):

picom &

指定配置文件启动

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

四、开机自动启动

1️⃣ 使用窗口管理器(如 i3)

在 ~/.i3/config 中添加:

exec --no-startup-id compton

2️⃣ 使用 Openbox

在 ~/.config/openbox/autostart 中添加:

compton &

3️⃣ systemd 用户级(不推荐用于桌面)

一般不建议,容易和桌面环境冲突。


五、常见问题

❌ 黑屏 / 无透明

  • 确保使用 GLX 后端
  • 显卡驱动正常(尤其是 NVIDIA)

❌ CPU 占用高

vsync = false;
unredir-if-possible = true;

❌ 与 GNOME/KDE 冲突

  • 桌面环境自带合成器,不要启用 compton

六、检查是否运行

ps aux | grep compton

如果你用的是 CentOS + i3 / Openbox / 特定显卡(NVIDIA/Intel),可以告诉我,我给你更精确的配置。

0 踩