在 Ubuntu 上配置 Compton(现在更多被称为 picom,Compton 已基本停止维护,picom 是其活跃分支),通常用于实现窗口透明、阴影、模糊等合成特效。下面我从安装 → 基础配置 → 自启动 → 常见问题一步步说明。
sudo apt update
sudo apt install picom
sudo apt install compton
以下以 picom 为例,配置方式完全兼容老 compton。
picom 默认读取:
~/.config/picom/picom.conf
创建目录和文件:
mkdir -p ~/.config/picom
nano ~/.config/picom/picom.conf
backend = "glx";
opacity-rule = [
"90:class_g = 'Firefox'"
];
shadow = true;
shadow-radius = 12;
shadow-opacity = 0.4;
shadow-offset-x = -5;
shadow-offset-y = -5;
fade = true;
fade-in-step = 0.03;
fade-out-step = 0.03;
backend = "glx";
blur-method = "gaussian";
blur-strength = 10;
unredir-if-possible = true;
opacity-rule = [
"100:fullscreen"
];
picom --config ~/.config/picom/picom.conf
或(默认配置):
picom
picom
nano ~/.config/systemd/user/picom.service
内容:
[Unit]
Description=picom compositor
[Service]
ExecStart=/usr/bin/picom
Restart=always
[Install]
WantedBy=default.target
启用:
systemctl --user enable picom
systemctl --user start picom
| 环境 | 说明 |
|---|---|
| i3 / bspwm / dwm | 必须手动启动 picom |
| GNOME | 不需要(自带合成) |
| XFCE | 可禁用自带合成后用 picom |
backend = "xrender";
opacity-rule = [
"80:class_g = '.*'"
];
picom --no-daemon --verbose
如果你告诉我:
我可以给你一份定制配置。