温馨提示×

centos compton配置啥步骤

小樊
49
2026-09-24 12:12:20
栏目: 智能运维

在 CentOS 上配置 Compton(窗口合成器,常用于 i3 / 无桌面环境时做透明、阴影、动画等),一般步骤如下:


一、安装 Compton

1. 启用 EPEL 源(CentOS 7)

sudo yum install -y epel-release
sudo yum install -y compton

CentOS 8 / Stream

sudo dnf install -y epel-release
sudo dnf install -y compton

如果仓库没有 compton,可用 picom(compton 的 fork):

sudo dnf install -y picom

二、创建配置文件

mkdir -p ~/.config/compton
vim ~/.config/compton/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-swc";

三、启动 Compton

手动测试

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

-b 表示后台运行

使用 picom

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

四、开机自动启动

1. 在 i3 中

在 ~/.config/i3/config 添加:

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

2. 普通桌面环境

mkdir -p ~/.config/autostart
vim ~/.config/autostart/compton.desktop

内容:

[Desktop Entry]
Type=Application
Exec=compton --config ~/.config/compton/compton.conf -b
Hidden=false
X-GNOME-Autostart-enabled=true
Name=Compton

五、常见问题

1. 黑屏 / 卡顿

  • 尝试换成 backend = "xrender"
  • 关闭 vsync

2. NVIDIA 显卡

  • 使用 xrender 更稳定
  • 避免 glx + 闭源驱动组合问题

3. 找不到 compton

  • CentOS 8+ 建议直接用 picom

如果你用的是 CentOS 几 + 桌面环境(GNOME/i3/无桌面),我可以给你更精确的配置。

0 踩