温馨提示×

compton centos如何启动

小樊
42
2026-10-17 21:49:40
栏目: 智能运维

你提到的 Compton 通常是一个在 Linux 上提供窗口透明、阴影、特效的 X11 合成器(compositor)。在 CentOS 上启动 Compton,一般步骤如下(假设你用的是 CentOS 7/8 且使用 X11 桌面,如 GNOME/MATE/XFCE):


一、安装 Compton

CentOS 7

sudo yum install epel-release
sudo yum install compton

CentOS 8 / Stream

sudo dnf install epel-release
sudo dnf install compton

如果找不到包,也可以从源码编译(不推荐新手)。


二、基本启动方式

1️⃣ 直接命令行启动

compton

或(后台运行):

compton &

如果你看到透明和阴影生效,说明成功了。


2️⃣ 使用配置文件启动(推荐)

创建配置文件:

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

示例配置(常用):

backend = "glx";
shadow = true;
fade = true;
opacity-rule = [
  "90:class_g = 'URxvt'"
];

然后启动:

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

三、开机自动启动(X11 桌面)

GNOME / MATE

mkdir -p ~/.config/autostart

创建文件:

nano ~/.config/autostart/compton.desktop

内容:

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

四、常见问题

❌ CentOS 默认用 Wayland(GNOME)

Compton 不支持 Wayland,必须切回 X11:

登录界面 → 齿轮 → 选择 GNOME on Xorg


❌ 黑屏 / 无效果

  • 确认是 X11 而不是 Wayland
  • 关闭其他 compositor(如 mutter 的合成)
  • 使用 compton --diagnostics 查看错误

五、额外说明

  • 新版项目已迁移为 picom
  • CentOS 上更推荐:
sudo dnf install picom
picom &

如果你能告诉我:

  • CentOS 版本
  • 桌面环境(GNOME / KDE / XFCE)
  • 是否 Wayland

我可以给你更精确的启动方案。

0 踩