Debian 上 Compton 使用教程
一 安装与准备
sudo apt update && sudo apt install comptonsudo apt install mesa-utils x11-xserver-utils wmctrl二 快速上手与配置
mkdir -p ~/.config && nano ~/.config/compton.confbackend = "glx"
vsync = "true"
shadow = true
fade = true
opacity-rule = [
"90:class_g 'Firefox'",
"90:name 'Terminal'"
]
shadow-exclude = [
"name 'Notification'",
"class_g ? 'Dmenu'",
"class_g ? 'Dunst'",
"_NET_WM_STATE@:32a * '_NET_WM_STATE_HIDDEN'"
]
killall compton && compton --config ~/.config/compton.conf &compton --config ~/.config/compton.conf -fbackend:渲染后端,常用 glx(OpenGL,性能更好)或 xrender(兼容性更好)。vsync:垂直同步,建议设为 true 减少撕裂。shadow / shadow-exclude:窗口阴影与排除列表(通知、菜单、悬浮面板等通常不显示阴影)。opacity-rule:按窗口类或名称设置透明度(取值 0.0–1.0)。三 开机自启与系统集成
exec --no-startup-id compton --config ~/.config/compton.confnano ~/.config/systemd/user/compton.service[Unit]
Description=Compton Compositor
After=graphical-session.target
[Service]
ExecStart=/usr/bin/compton --config /home/你的用户名/.config/compton.conf
Restart=always
RestartSec=5
[Install]
WantedBy=graphical-session.target
systemctl --user daemon-reloadsystemctl --user enable --now compton.serviceps -e | grep comptonsystemctl --user status compton.service(若使用 systemd)四 常见问题与优化
shadow = false,或对通知类窗口排除阴影以减轻合成负担。cpulimit -l 50 -p $(pgrep compton)backend、关闭 vsync 测试,或暂时用纯色背景排查第三方主题/插件。shadow-exclude、opacity-rule 是否误伤目标窗口;模糊对性能更敏感,低配机器可关闭。mesa-utils 辅助诊断。