温馨提示×

compton centos如何启用

小樊
57
2026-10-26 18:41:05
栏目: 智能运维

你提到的 Compton 是一个常见的 X11 合成器(窗口透明、阴影、动画等),在 CentOS 上启用它通常步骤如下(以 CentOS 7/8 为例,假设使用 X11 而非 Wayland)。


一、确认环境

Compton 只支持 X11,不支持 Wayland。

echo $XDG_SESSION_TYPE
  • 如果是 x11 ✅ 可以继续
  • 如果是 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-x

三、创建配置文件(可选但推荐)

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

最简配置示例:

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

四、启动 Compton

手动测试

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

开机自启(GNOME / KDE)

  • GNOME:
    打开 gnome-session-properties

    gnome-session-properties
    

    添加:

    compton --config ~/.config/compton/compton.conf
    
  • i3 / 其他 WM:
    在 ~/.xinitrc 或 WM 配置中加入:

    compton -b
    

五、常见问题

1. 黑屏 / 卡顿

尝试:

compton --backend xrender

2. NVIDIA 显卡

建议在配置中加:

backend = "glx";
glx-no-stencil = true;
vsync = "opengl-swc";

3. CentOS 9+

Compton 已被 picom 取代:

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

如果你能告诉我:

  • CentOS 版本
  • 桌面环境(GNOME / KDE / i3)
  • 是否 NVIDIA

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

0 踩