温馨提示×

centos compton怎么配置

小樊
54
2026-09-06 09:39:43
栏目: 智能运维

在 CentOS 上配置 Compton(一个轻量级 X11 合成管理器,常用于 i3 / Openbox 等环境),一般步骤如下:


一、安装 Compton

CentOS 7

sudo yum install epel-release
sudo yum install compton

CentOS 8 / Stream

sudo dnf install epel-release
sudo dnf install compton

如果仓库里没有,可以用源码编译或从 COPR 安装。


二、创建配置文件

Compton 默认读取:

~/.config/compton.conf

创建目录和文件:

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

基础配置示例(常用)

# 后端
backend = "glx";

# 开启阴影
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;

# 不透明窗口检测
detect-rounded-corners = true;
detect-client-opacity = true;

# 排除某些窗口(如全屏)
unredir-if-possible = true;

# GLX 设置
glx-no-stencil = true;
glx-copy-from-front = false;

三、启动 Compton

手动启动

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

-b 表示后台运行。

开机自启(i3 示例)

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

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

Openbox 自启

编辑 ~/.config/openbox/autostart:

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

四、常见问题

1. 黑屏 / 卡顿

尝试切换后端:

backend = "xrender";

2. NVIDIA 显卡

建议:

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

并确保安装了专有驱动。

3. 全屏游戏掉帧

unredir-if-possible = true;

五、调试方式

前台运行看日志:

compton --config ~/.config/compton.conf --show-all-errors

如果你用的是 CentOS 具体版本 + 桌面环境(i3 / GNOME / KDE),我可以给你更精确的配置。

0 踩