温馨提示×

centos下compton怎样配置

小樊
46
2026-09-18 09:49:34
栏目: 智能运维

在 CentOS 下配置 compton(窗口合成器,常用于 i3 / Openbox 等轻量桌面),一般流程如下:


一、安装 compton

CentOS 默认仓库里不一定有 compton,常见方式:

1. 使用 EPEL(推荐先试)

sudo yum install -y epel-release
sudo yum install -y compton

2. 若仓库没有(常见)

可从源码编译:

sudo yum groupinstall -y "Development Tools"
sudo yum install -y \
  libconfig-devel dbus-devel xcb-devel \
  libX11-devel libXext-devel libXrender-devel \
  libXrandr-devel libXinerama-devel libXcursor-devel \
  mesa-libGL-devel pcre-devel

git clone https://github.com/chjj/compton.git
cd compton
make
sudo make install

二、创建配置文件

配置文件通常位于:

~/.config/compton.conf

示例配置(常用、稳定):

# 后端
backend = "glx";

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

# 透明度
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;

# 忽略某些窗口
no-dock-shadow = true;
no-dnd-shadow = true;

三、启动 compton

1. 手动测试

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

2. 开机自启(以 i3 为例)

~/.i3/config 中加入:

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

若是 Openbox:

~/.config/openbox/autostart

添加:

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

四、常见问题

1. 黑屏 / 卡顿

尝试:

backend = "xrender";
vsync = false;

2. NVIDIA 显卡

建议:

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

3. 查看是否运行

ps aux | grep compton

如果你能说明:

  • CentOS 版本(7 / 8 / Stream)
  • 桌面环境(i3 / Openbox / 无桌面)
  • 显卡类型

我可以给你一套更精准的配置

0