温馨提示×

centos compton怎样启用

小樊
56
2026-10-15 01:18:51
栏目: 智能运维

在 CentOS 上“启用 Compton”通常指的是:安装并让 Compton 作为窗口合成器(compositor)在登录后自动运行,常用于 i3 / Openbox / Fluxbox 等轻量桌面环境。

下面按常见场景说明(CentOS 7 / 8 / Stream 通用思路)。


一、确认环境

Compton 需要 X11(不是纯 Wayland)。

echo $XDG_SESSION_TYPE

输出应为 x11。

如果你用的是:

  • GNOME(默认 Wayland 或自带合成器)→ 一般不需要 Compton
  • i3 / Openbox / 裸 X → 非常适合用 Compton

二、安装 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 xcompmgr

若仓库没有 compton,可用 picom(Compton 的继任者):

sudo dnf install picom

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

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

最小示例:

backend = "glx";
vsync = true;
shadow = true;
fade = true;

四、手动启动测试

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

或(无配置):

compton &

如果窗口出现阴影、透明生效,说明成功。


五、开机自动启用

方式 1:i3 用户(最常见)

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

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

方式 2:Openbox

编辑 ~/.config/openbox/autostart:

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

方式 3:通用 X11(.xinitrc)

echo "compton &" >> ~/.xinitrc

六、常见问题

1. 黑屏 / 卡顿

尝试:

compton --backend xrender

2. 想用 picom 替代

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

3. 查看是否在运行

ps aux | grep compton

七、一句话总结

CentOS 启用 Compton = 安装 compton → 配置 → 在桌面环境 autostart 里加 compton &

如果你能告诉我:

  • CentOS 版本
  • 用的桌面(i3 / GNOME / Openbox)

我可以给你精确可用的配置和启动方式。

0 踩