在 Linux 下使用 Compton(现在多数发行版已改名为 picom,但配置方式基本一样)时,配置文件通常是:
~/.config/compton.conf~/.config/picom.conf下面给你一个从零开始的 Compton 配置示例和说明。
sudo apt install compton
sudo pacman -S compton
如果是新系统,推荐:
sudo pacman -S picom
mkdir -p ~/.config
touch ~/.config/compton.conf
# 后端
backend = "glx";
# 阴影
shadow = true;
shadow-radius = 8;
shadow-opacity = 0.5;
shadow-offset-x = -2;
shadow-offset-y = -2;
shadow-exclude = [
"name = 'Notification'",
"class_g = 'Conky'",
"_GTK_FRAME_EXTENTS@:c"
];
# 透明度
opacity-rule = [
"90:class_g = 'URxvt'",
"95:class_g = 'Firefox'"
];
# 淡入淡出
fading = true;
fade-in-step = 0.03;
fade-out-step = 0.03;
# 刷新率无关
vsync = true;
# 忽略某些窗口
unredir-if-possible = true;
# 不做合成的窗口
no-dock-shadow = true;
no-dnd-shadow = true;
# 性能
glx-no-stencil = true;
glx-copy-from-front = false;
compton --config ~/.config/compton.conf &
在 ~/.config/i3/config 中:
exec --no-startup-id compton --config ~/.config/compton.conf
| 参数 | 说明 |
|---|---|
shadow |
是否启用阴影 |
fade |
窗口淡入淡出 |
opacity-rule |
按窗口类设置透明度 |
vsync |
防撕裂 |
backend |
glx / xrender |
unredir-if-possible |
全屏时关闭合成(游戏更流畅) |
查看是否在运行:
ps aux | grep compton
强制重载:
killall compton
compton --config ~/.config/compton.conf &
查看错误:
compton --config ~/.config/compton.conf --log-level DEBUG
如果你用的是 i3 / bspwm / awesome / KDE / GNOME,或者想做 模糊(blur),我可以给你更针对性的配置。