Ubuntu 下正确设置 Compton 参数
一 环境准备与注意事项
sudo apt update && sudo apt install compton;用 ps -e | grep compton 检查是否已运行。二 配置文件与关键参数
mkdir -p ~/.config && nano ~/.config/compton.conf。# 渲染与同步
backend = "glx" # 优先使用 GPU 加速;若异常可改为 "xrender"
vsync = "true" # 减少撕裂,代价是可能略降帧率
# 阴影与模糊
shadow = true
shadow-radius = 12
shadow-offset-x = 0
shadow-offset-y = 4
shadow-exclude = [
"class_g = 'Conky'",
"class_g = 'Polybar'",
"_NET_WM_WINDOW_TYPE@:a = 'dock'"
]
# 透明度与窗口规则
opacity-rule = [
"90:class_g = 'URxvt'",
"0.95:class_g = 'Firefox'"
]
# 帧率与渲染质量
fps-limit = 60
use-damage = true
三 启动与自启
compton --config ~/.config/compton.confkillall compton && compton --config ~/.config/compton.confcompton --config ~/.config/compton.conf。# ~/.config/systemd/user/compton.service
[Unit]
Description=Compton Compositor
After=graphical-session.target
[Service]
ExecStart=/usr/bin/compton --config %h/.config/compton.conf
Restart=on-failure
[Install]
WantedBy=graphical-session.target
启用:systemctl --user daemon-reload && systemctl --user enable --now compton.service。
四 性能优化与常见问题
shadow = false。shadow-exclude、opacity-rule 精准控制窗口效果,避免全局透明。top/htop 观察 compton 占用。