首页/发现新知
视界 · 深度阅读

compton在centos咋配置

你指的 Compton 一般是 Linux 下的一个轻量级 X11 合成器(窗口透明、阴影、模糊等),在 CentOS 上配置步骤如下(以 CentOS 7 / 8 为例,9 也类似)。


一、安装 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 git make gcc libconfig-devel dbus-devel pam-devel xcb-util-devel
git clone https://github.com/yshui/compton.git
cd compton
make
sudo make install

二、基本配置文件

Compton 默认读取:

~/.config/compton.conf

示例配置(常用):

backend = "glx";
glx-no-stencil = true;
glx-copy-from-front = false;

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

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

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

vsync = "opengl-swc";
unredir-if-possible = true;

三、启动 Compton

手动启动

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

-b 表示后台运行

开机自启(无桌面环境)

加到 ~/.xinitrc 或 ~/.xprofile:

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

GNOME / KDE

  • GNOME 已有自带合成器,不建议叠加 Compton
  • 若用 i3 / Openbox / Fluxbox:
echo "exec compton -b" >> ~/.config/i3/config

四、常见问题

1. 黑屏 / 卡顿

尝试:

backend = "xrender";

或关闭 vsync:

vsync = false;

2. NVIDIA 显卡

建议:

backend = "glx";
glx-no-stencil = true;

3. CentOS 9 没有 compton

可用 picom(Compton 分支):

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

五、检查是否运行

ps aux | grep compton

如果你能告诉我:

  • CentOS 版本
  • 用的是哪个桌面(GNOME / KDE / i3 / 无桌面)

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

读到这里,发现更多一点。探索更多内容 ↗