Ubuntu 上安装与启用 Compton 的关键注意事项
一 会话与桌面环境适配
二 安装与版本选择
sudo apt update && sudo apt install compton。安装后可用 compton --version 验证。ppa:compton-compositor/stable),或自行从源码编译。cmake、libx11-dev、libwayland-dev、libxrandr-dev、mesa-common-dev 等,编译安装后同样用 compton --version 校验。三 配置与自启动要点
backend = glx(或 xrender),不同硬件与驱动下性能/兼容性表现不同,必要时切换对比。vsync = true/false,开可减轻撕裂,关可提升帧率,按显示器与显卡特性取舍。shadow = true/false,opacity 与 [opacity-rule] 用于按窗口类/名称设置透明度。killall compton && compton --config ~/.config/compton.conf & 使配置生效。compton --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。sudo systemctl restart compton 这种系统级方式管理用户会话的合成器。四 驱动与性能调优
xrender 后端以提升稳定性。glxgears/glxgears-ng、x11perf 做基础渲染测试,配合 htop/top 与(NVIDIA)nvidia-smi 观察 CPU/GPU 使用率,定位瓶颈。五 常见问题快速排查
ps -e | grep compton 查看进程;必要时 killall compton 后重新启动。backend(glx/xrender)、调整 vsync、关闭阴影/模糊;检查显示器刷新率与驱动版本。opacity-rule 的格式),用 compton --config <你的配置> -f 前台运行观察报错信息。