在 Linux 上让 compton(现在多称为 picom)开启窗口/桌面透明,主要通过配置文件实现。下面按常见场景说明。
compton --version
# 或
picom --version
如果没有:
# Debian / Ubuntu
sudo apt install compton
# Arch
sudo pacman -S picom
mkdir -p ~/.config/compton
compton --config ~/.config/compton/compton.conf --dump > ~/.config/compton/compton.conf
(如果是 picom,把 compton 换成 picom)
编辑 ~/.config/compton/compton.conf
opacity-rule = [
"90:class_g = '.*'",
"80:class_g = 'URxvt'",
"70:class_g = 'Firefox'"
];
意思是:
inactive-opacity = 0.8;
active-opacity = 1.0;
效果:
focus-exclude = "x = 0 && y = 0 && override_redirect = true";
如果你用的是 i3 / bspwm / openbox,可以配合:
backend = "glx";
并确保开启:
glx-fshader-win = """
uniform sampler2D tex;
void main() {
gl_FragColor = texture2D(tex, gl_TexCoord[0].xy);
}
""";
compton --config ~/.config/compton/compton.conf -b
或(picom):
picom --config ~/.config/compton/compton.conf -b
-b 表示后台运行。
在 ~/.config/i3/config 中加:
exec --no-startup-id compton --config ~/.config/compton/compton.conf -b
xprop 查 class 名是否正确unredir-if-possible = true;
如果你告诉我:
我可以给你一份可直接用的配置。