温馨提示×

compton在centos怎么设

小樊
40
2026-10-20 19:13:55
栏目: 智能运维

你提到的 Compton 一般是指 Linux 下的轻量级 X11 合成器(现在社区里更多是它的继任者 picom)。下面分别说明在 CentOS 上如何安装和配置。


一、安装 Compton / Picom

1. CentOS 7

CentOS 7 官方源里没有 compton,需要 EPEL 或手动编译:

sudo yum install epel-release
sudo yum install compton

如果没有包:

# 手动编译(示例)
sudo yum install git gcc make libconfig-devel dbus-devel xcb-devel
git clone https://github.com/chjj/compton.git
cd compton
make
sudo make install

2. CentOS 8 / Stream

推荐直接用 picom(compton 的维护分支):

sudo dnf install picom

或:

sudo dnf install epel-release
sudo dnf install picom

二、基础配置(~/.config/compton.conf 或 picom.conf)

示例配置(透明 + 阴影 + 淡入淡出):

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

shadow = true;
shadow-radius = 8;
shadow-offset-x = -2;
shadow-offset-y = -2;
shadow-opacity = 0.4;

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

vsync = true;

三、启动 Compton

手动启动

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

或 picom:

picom --config ~/.config/picom.conf -b

开机自启(以 i3 / 普通桌面为例)

在 ~/.xinitrc 或桌面环境自启里加:

compton -b &

四、常见问题

  1. 黑屏 / 无透明

    • 确认使用的是 X11 而不是 Wayland
    • 检查显卡驱动(尤其是 NVIDIA)
  2. CentOS 默认是 GNOME + Wayland

    • 注销 → 登录时选 “GNOME on Xorg”
  3. 性能差

    • 改用 backend = "xrender"

如果你能说明:

  • CentOS 版本(7 / 8 / Stream)
  • 桌面环境(GNOME / KDE / i3 / 无桌面)
  • 用的是 compton 还是 picom

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

0 踩