在 Linux 上配置 Compton 实现透明效果
一 准备与安装
sudo apt update && sudo apt install comptonsudo dnf install comptonsudo pacman -S compton二 创建基础配置
mkdir -p ~/.config && nano ~/.config/compton.confbackend = "glx"
vsync = true
fade = true
shadow = true
[opacity-rule]
"90:class_g 'Firefox'"
"90:name 'Terminal'"
"100:class_g 'Xephyr'"
opacity-rule 使用“透明度:匹配条件”的格式;class_g 匹配窗口的类名(不区分大小写),name 匹配窗口名。上述示例将 Firefox 与 Terminal 设为 90% 不透明(即 10% 透明),Xephyr 保持不透明。三 启动与自启动
compton --config ~/.config/compton.conf~/.config/autostart/compton.desktop[Desktop Entry]
Type=Application
Exec=compton --config ~/.config/compton.conf
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Compton
~/.config/systemd/user/compton.service[Unit]
Description=Compton Compositor
After=graphical-session.target
[Service]
ExecStart=/usr/bin/compton --config %h/.config/compton.conf
Restart=always
[Install]
WantedBy=default.target
启用:systemctl --user daemon-reload && systemctl --user enable --now compton四 进阶与常见问题
[blur]
method = gaussian
size = 10
deviation = 5.0
shadow-exclude = ["x 0 && y 0 && override_redirect true"]
focus-exclude = "x 0 && y 0 && override_redirect true"
vsync 设为 true。--log-level debug)。