Ubuntu 下 Compton 配置全流程
一 安装与准备
二 配置文件位置与最小可用示例
# 渲染后端:glx 通常性能更好;若出现花屏/卡顿可改为 xrender
backend = "glx"
# 垂直同步:减少撕裂;若游戏/拖动窗口掉帧可尝试 false
vsync = true
# 阴影
shadow = true
shadow-radius = 12
shadow-offset-x = 1
shadow-offset-y = 1
shadow-opacity = 0.45
# 淡入淡出动画
fade = true
fade-delta = 10
# 窗口透明度(示例:对某些程序设为 0.92)
opacity-rule = [
"90:class_g = 'Alacritty'",
"92:class_g = 'Firefox'"
];
# 模糊(可选,性能开销较大)
blur = {
method = "gaussian"
size = 6
deviation = 3.0
}
# 排除阴影的窗口(正则/类匹配)
shadow-exclude = [
"name = 'Notification'",
"class_g = 'Conky'",
"class_g = 'Polybar'"
];
三 启动与开机自启
[Unit]
Description=Compton Window Composer
After=graphical-session.target
[Service]
ExecStart=/usr/bin/compton --config %h/.config/compton.conf --log-file=%h/.local/share/compton.log
Restart=on-failure
[Install]
WantedBy=default.target
systemctl --user daemon-reload
systemctl --user enable --now compton.service
[Unit]
Description=Compton Window Composer
After=display-manager.service
[Service]
ExecStart=/usr/bin/compton --config /etc/xdg/compton.conf
Restart=on-failure
[Install]
WantedBy=multi-user.target
四 常用调优与排错