在 Ubuntu 中使用 Compton 进行窗口管理
一 概念与适用场景
二 安装与快速启动
sudo apt update
sudo apt install compton
compton
killall compton
compton --config ~/.config/compton.conf &
sudo systemctl restart compton 通常会失败;如需自启动,见下文“自启动方案”。三 配置要点与示例
backend = "glx"
vsync = true
shadow = true
fade = true
opacity = 0.9
[shadow]
shadow-radius = 5
shadow-offset-x = 1
shadow-offset-y = 1
shadow-opacity = 0.3
[blur]
method = gaussian
size = 10
deviation = 5.0
[opacity-rule]
90:class_g 'Firefox'
95:name 'Terminal'
killall compton
compton --config ~/.config/compton.conf &
shadow-exclude 或 opacity-rule 中按 class/name 精确排除或设定规则。四 自启动与系统集成
[Unit]
Description=Compton Compositor
After=graphical-session.target
[Service]
ExecStart=/usr/bin/compton --config %h/.config/compton.conf
Restart=on-failure
Environment=DISPLAY=:0
[Install]
WantedBy=graphical-session.target
systemctl --user daemon-reload
systemctl --user enable --now compton.service
compton --config ~/.config/compton.conf &
pgrep -x comptoncompton --log-file=/tmp/compton.log --log-level=debug五 常见问题与排错
shadow-exclude、opacity-rule 精确匹配问题应用(按 class/name),必要时关闭该应用的模糊或透明。compton --log-file=/tmp/compton.log --log-level=debug