温馨提示×

centos如何弄compton配置

小樊
47
2026-10-23 20:21:32
栏目: 智能运维

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


一、安装 compton

CentOS 默认仓库里一般没有 compton,可以:

1️⃣ 使用 EPEL(如果有旧包)

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

⚠️ CentOS 7/8 的 EPEL 中 compton 可能不存在或版本很旧
推荐用 picom(compton 的活跃分支)


2️⃣ 安装 picom(推荐)

sudo yum install -y picom

如果仓库没有:

sudo yum install -y git make gcc libconfig-devel \
  libX11-devel libXcomposite-devel libXdamage-devel \
  libXrandr-devel libXinerama-devel libXcursor-devel \
  pixman-devel dbus-devel

git clone https://github.com/yshui/picom.git
cd picom
meson --buildtype=release . build
ninja -C build
sudo ninja -C build install

二、创建 compton / picom 配置文件

配置文件通常位于:

~/.config/compton.conf
# 或(picom)
~/.config/picom.conf

示例配置(常用)

# 阴影
shadow = true;
shadow-radius = 12;
shadow-opacity = 0.5;
shadow-offset-x = -2;
shadow-offset-y = -2;

# 透明度
inactive-opacity = 0.9;
active-opacity = 1.0;

# 淡入淡出
fading = true;
fade-in-step = 0.03;
fade-out-step = 0.03;

# 后端
backend = "glx";
vsync = true;

# 忽略全屏
unredir-if-possible = true;

三、启动 compton

临时启动

compton &
# 或
picom &

开机自启(i3 示例)

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

exec --no-startup-id picom

Openbox 自启

编辑 ~/.config/openbox/autostart:

picom &

四、调试常见问题

❌ 透明无效

  • 确认窗口管理器支持 compositing
  • 使用 backend = "xrender" 试试

❌ 闪屏 / 卡顿

vsync = false;
backend = "xrender";

❌ 黑屏

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

五、compton vs picom 建议

项目 compton picom
维护状态 ❌ 停止 ✅ 活跃
功能 基础 更全
推荐 ❌ ✅

如果你告诉我:

  • CentOS 版本(7 / 8 / Stream)
  • 桌面环境(i3 / openbox / 无桌面)

我可以给你精确的配置和命令。

0 踩