温馨提示×

centos如何让compton运行

小樊
34
2026-10-17 21:50:40
栏目: 智能运维

在 CentOS 上让 compton(窗口合成器,常用于 i3 / 轻量桌面)运行,一般步骤如下:


一、安装 compton

CentOS 7

sudo yum install epel-release
sudo yum install compton

CentOS 8 / Stream

sudo dnf install epel-release
sudo dnf install compton

如果仓库中没有 compton,可以改用 picom(compton 的活跃分支):

sudo dnf install picom

二、准备配置文件(可选但推荐)

创建配置文件:

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

示例配置(适合 i3):

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

三、启动 compton

手动测试

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

或(picom):

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

如果没有报错,说明可以运行。


四、开机自动启动

如果你用 i3

在 ~/.config/i3/config 中加入:

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

如果你用 systemd 用户会话

systemctl --user enable compton
systemctl --user start compton

(CentOS 8 / Stream 更推荐这种方式)


五、常见问题

1. 黑屏 / 无效果

  • 确认使用的是 GLX 或 XRender
  • 关闭 vsync 试试
  • 显卡驱动是否正常(尤其是 NVIDIA)

2. CentOS 使用 NVIDIA

建议加:

backend = "xrender";

或:

compton --backend xrender

3. compton 命令不存在

说明装的是 picom:

which picom

六、检查是否在运行

ps aux | grep compton

如果你能告诉我:

  • CentOS 版本
  • 用的是哪种桌面(i3 / XFCE / 无桌面)
  • 显卡类型

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

0 踩