在 Ubuntu 上配置 Compton(现在社区更常用其分支 Picom)通常用于为窗口管理器(如 i3、Openbox、Awesome 等)提供窗口透明、阴影、模糊等合成效果。
下面以 Compton / Picom 为例说明配置步骤。
sudo apt update
sudo apt install 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
# 阴影
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 &
在 ~/.config/i3/config 中添加:
exec --no-startup-id picom
其他桌面环境可加到:
~/.xinitrc| 参数 | 作用 |
|---|---|
shadow |
是否启用阴影 |
opacity-rule |
按窗口类设置透明度 |
blur-background |
背景模糊(picom 支持) |
vsync |
防止画面撕裂 |
unredir-if-possible |
全屏不合成(游戏更流畅) |
blur-method = "gaussian";
blur-strength = 10;
blur-background = true;
查看错误:
picom --diagnostics
前台运行:
picom --no-daemon
如果你用的是 Ubuntu 桌面版(GNOME) 或 特定窗口管理器(i3 / Awesome / XFCE),可以告诉我,我可以给你更精确的配置。