温馨提示×

centos怎么装compton配置

小樊
40
2026-09-30 10:02:29
栏目: 智能运维

在 CentOS 上安装和配置 compton(一个轻量级 X11 合成管理器,常用于 i3 / openbox 等窗口管理器实现透明、阴影、淡入淡出等效果),可以按下面的步骤来。


一、安装 Compton

1. 启用 EPEL 源(CentOS 7)

sudo yum install -y epel-release

2. 安装 compton

CentOS 7 可直接用 yum:

sudo yum install -y compton

⚠️ 注意:

  • CentOS 8 / Stream 默认仓库可能没有 compton
  • 可用 picom(compton 的 fork)代替

3. 若仓库没有 compton(CentOS 8 / Stream)

安装 picom:

sudo dnf install -y picom

(下面配置对 compton / picom 基本通用)


二、创建配置文件

Compton 默认读取:

~/.config/compton.conf

创建目录和文件:

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

基础配置示例(常用)

# 后台运行
daemon = true;

# 透明设置
opacity-rule = [
  "90:class_g = 'URxvt'",
  "95:class_g = 'Firefox'"
];

# 阴影
shadow = true;
shadow-opacity = 0.5;
shadow-radius = 10;
shadow-offset-x = -5;
shadow-offset-y = -5;

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

# 刷新率相关
vsync = "opengl-swc";

# 后端
backend = "glx";

三、启动 Compton

手动启动

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

开机自动启动(i3 示例)

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

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

Openbox 自动启动

编辑:

~/.config/openbox/autostart

添加:

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

四、常见问题

1. 透明无效

  • 确保使用 Composite 扩展
  • 确认窗口管理器支持(i3 / openbox 支持)
  • 检查是否是 backend = "xrender" 导致问题,可改 glx

2. CentOS 8 没 compton

直接用 picom,命令基本一致:

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

3. 黑屏 / 卡顿

尝试:

backend = "xrender";
vsync = false;

如果你告诉我:

  • CentOS 版本(7 / 8 / Stream)
  • 用的窗口管理器(i3 / openbox / 无)

我可以给你更精确的配置和启动方式。

0 踩