温馨提示×

compton centos配置方法

小樊
44
2026-10-20 19:17:57
栏目: 智能运维

你提到的 “Compton” 通常是指在 Linux 桌面环境下用于实现窗口透明、阴影、合成特效的轻量级合成器(现在更多被 picom 取代,但配置方式基本相同)。下面以 CentOS(以 CentOS 7 / 8 为例,桌面环境如 GNOME、XFCE、MATE)来说明 Compton 的安装与配置方法。


一、安装 Compton

1. 启用 EPEL 源(CentOS 7)

sudo yum install -y epel-release

2. 安装 Compton

sudo yum install -y compton

CentOS 8 可使用:

sudo dnf install -y compton

(若仓库中没有,可考虑使用 picom,命令类似)


二、创建 Compton 配置文件

配置文件一般放在:

~/.config/compton.conf

示例配置(常用):

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

# 阴影
shadow = true;
shadow-radius = 12;
shadow-offset-x = -3;
shadow-offset-y = -3;
shadow-opacity = 0.4;

# 合成模式
backend = "glx";
vsync = true;

# 避免全屏卡顿
unredir-if-possible = true;

# 背景模糊(可选)
blur-background = true;
blur-background-frame = true;

三、启动 Compton

1. 手动启动

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

2. 开机自启(XFCE / MATE)

  • 打开「会话和启动」
  • 添加启动项:
    • 名称:Compton
    • 命令:compton --config ~/.config/compton.conf

3. GNOME(不推荐)

GNOME 默认使用 Mutter,Compton 可能冲突,建议:

  • 使用 XFCE / MATE
  • 或改用 picom

四、常见问题

1. 透明无效

  • 确保窗口管理器支持 RGBA
  • 启动时使用:
compton --backend glx --vsync opengl

2. 屏幕闪烁

尝试:

vsync = false;

3. CentOS 无 compton 包

可编译安装:

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

五、Compton 与 Picom 的关系

  • Compton 已停止维护
  • Picom 是 Compton 的活跃分支
  • 配置基本兼容

安装 picom(推荐):

sudo yum install picom

如果你能说明:

  • CentOS 版本(7 / 8 / Stream)
  • 桌面环境(GNOME / XFCE / MATE)
  • 使用目的(透明 / 阴影 / 录屏)

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

0 踩