温馨提示×

compton在centos怎样启用

小樊
34
2026-09-18 09:54:33
栏目: 智能运维

你提到的 Compton 通常是指 Linux 下的 Compton 合成器(compositor),用于实现窗口透明、阴影、模糊等特效。在 CentOS 上启用 Compton,一般步骤如下(以 CentOS 7 / 8 为例,CentOS Stream 类似):


一、确认环境

Compton 需要:

  • 已安装 X11 桌面(如 GNOME、MATE、XFCE)
  • 使用 Xorg 而非纯 Wayland(CentOS 默认 GNOME 可能是 Wayland)

查看当前会话:

echo $XDG_SESSION_TYPE

如果是 wayland,建议切换到 X11(注销后在登录界面选择 “GNOME on Xorg”)。


二、安装 Compton

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 compton --enablerepo=epel

三、创建配置文件

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

示例配置:

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

四、启动 Compton

手动测试

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

-b 表示后台运行。


开机自动启动

GNOME / MATE:

  • 设置 → 启动应用程序 → 添加
  • 命令:
compton --config ~/.config/compton/compton.conf -b

i3 / 其他 WM:~/.xinitrc 或 WM 配置中加入:

compton -b &

五、常见问题

1. 黑屏 / 卡顿

尝试:

backend = "xrender";

或关闭 shadow:

shadow = false;

2. NVIDIA 显卡

建议加:

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

3. CentOS 默认无 Compton

CentOS 默认用 mutter(GNOME 自带合成器),不需要 Compton。
只有在 i3 / Openbox / 轻量桌面 才需要。


六、替代方案(推荐)

Compton 已停止维护,新项目是 picom

sudo dnf install picom
picom --config ~/.config/picom/picom.conf -b

如果你能告诉我:

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

我可以给你更精确的配置。

0