温馨提示×

怎样配置ubuntu compton

小樊
46
2026-09-07 05:27:24
栏目: 智能运维

在 Ubuntu 上配置 Compton(现在社区更常用其分支 Picom)通常用于为窗口管理器(如 i3、Openbox、Awesome 等)提供窗口透明、阴影、模糊等合成效果。

下面以 Compton / Picom 为例说明配置步骤。


一、安装 Compton / Picom

1. 安装 Compton(旧版)

sudo apt update
sudo apt install compton

2. 或安装 Picom(推荐,Compton 的维护分支)

sudo apt install picom

Ubuntu 20.04+ 推荐用 picom


二、创建配置文件

Compton / Picom 默认读取:

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

创建配置目录和文件:

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

三、基础配置示例(compton.conf / picom.conf)

简单透明 + 阴影

# 阴影
shadow = true;
shadow-radius = 8;
shadow-opacity = 0.6;
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;

# 其他
backend = "glx";
vsync = true;

四、启动 Compton / Picom

手动启动

compton &
# 或
picom &

开机自动启动(以 i3 为例)

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

exec --no-startup-id picom

其他桌面环境可加到:

  • 启动应用
  • ~/.xinitrc
  • 显示管理器自启

五、常用参数说明

参数 作用
shadow 是否启用阴影
opacity-rule 按窗口类设置透明度
blur-background 背景模糊(picom 支持)
vsync 防止画面撕裂
unredir-if-possible 全屏不合成(游戏更流畅)

六、Picom 模糊示例(推荐)

blur-method = "gaussian";
blur-strength = 10;
blur-background = true;

七、调试

查看错误:

picom --diagnostics

前台运行:

picom --no-daemon

如果你用的是 Ubuntu 桌面版(GNOME) 或 特定窗口管理器(i3 / Awesome / XFCE),可以告诉我,我可以给你更精确的配置。

0 踩