温馨提示×

centos compton怎么开启

小樊
40
2026-10-03 07:32:31
栏目: 智能运维

在 CentOS 上“开启 Compton”通常是指使用 compton 作为合成器(compositor)来实现窗口透明、阴影、动画等效果。下面按常见场景给你说明。


一、确认你用的是哪种桌面环境

Compton 一般用于:

  • i3 / bspwm / openbox 等轻量窗口管理器
  • GNOME / KDE 一般自带合成器,不需要 compton

如果你用的是 GNOME,通常不需要 compton。


二、安装 Compton(CentOS 7 / 8)

CentOS 7

sudo yum install epel-release
sudo yum install compton

CentOS 8 / Stream

sudo dnf install epel-release
sudo dnf install compton

如果没有包(某些版本),可以源码编译:

sudo dnf install libconfig-devel dbus-devel mesa-libGL-devel
git clone https://github.com/chjj/compton
cd compton
make
sudo make install

三、启动 Compton

1️⃣ 手动测试

compton &

如果能看到透明效果,说明成功了。


2️⃣ 开机自动启动(i3 示例)

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

exec --no-startup-id compton

3️⃣ 其他窗口管理器

  • Openbox:~/.config/openbox/autostart
  • bspwm:~/.config/bspwm/bspwmrc

加入:

compton &

四、基本配置文件(推荐)

创建:

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

示例:

backend = "glx";
glx-no-stencil = true;
shadow = true;
fade = true;
opacity-rule = [
  "90:class_g = 'URxvt'",
  "95:class_g = 'Firefox'"
];

然后启动:

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

五、常见问题

❌ 黑屏 / 闪屏

尝试:

compton --backend xrender

❌ NVIDIA 显卡

加参数:

compton --vsync opengl

六、替代方案(2024+ 推荐)

Compton 已停更,建议使用:

  • picom(compton 分支)
sudo dnf install picom
picom &

如果你能告诉我:

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

我可以给你精确到命令的配置方案。

0 踩