温馨提示×

怎样在centos用compton

小樊
47
2026-09-24 12:11:21
栏目: 智能运维

在 CentOS 上使用 compton(一个轻量级 X11 合成管理器,常用于 i3 / Openbox 等窗口管理器实现透明和阴影效果),一般步骤如下:


一、安装 compton

1. 启用 EPEL 源(如未启用)

sudo yum install -y epel-release

2. 安装 compton

sudo yum install -y compton

某些 CentOS 版本仓库中是 compton,新版本可能叫 picom(compton 的分支):

sudo yum install -y picom

二、基本使用方式

1. 直接在终端启动

compton &

或(picom):

picom &

2. 使用配置文件(推荐)

创建配置文件:

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

示例配置(常用):

backend = "glx";
shadow = true;
shadow-radius = 10;
shadow-opacity = 0.5;
shadow-offset-x = -5;
shadow-offset-y = -5;

opacity-rule = [
  "90:class_g = 'URxvt'",
  "95:class_g = 'Firefox'"
];

fading = true;
fade-in-step = 0.03;
fade-out-step = 0.03;

vsync = true;

启动:

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

三、在窗口管理器中自动启动

i3 示例

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

exec --no-startup-id compton

Openbox 示例

在 ~/.config/openbox/autostart 中:

compton &

四、常见问题

1. 黑屏 / 无透明效果

  • 确认使用的是 X11(不是 Wayland)
  • 确认显卡驱动正常(尤其是 NVIDIA)
  • 尝试:
compton --backend xrender

2. NVIDIA 用户

建议:

backend = "xrender";
vsync = "none";

3. CentOS 8 无 compton 包

使用 picom 或自己编译:

sudo dnf install picom

五、调试

查看日志:

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

如果你能告诉我:

  • CentOS 版本(7 / 8 / Stream)
  • 使用的桌面环境(GNOME / i3 / 无桌面)
  • 是否 NVIDIA 显卡

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

0 踩