Ubuntu 上让 Compton 与 GNOME 稳定共存的要点
在 Ubuntu 的 GNOME 会话中,Mutter 已经内置合成器。直接再运行 Compton 往往会造成合成器“打架”(撕裂、卡顿、阴影异常)。正确做法是:要么使用 GNOME 自带合成器,要么切换到不自带合成器的会话(如 i3 或 Openbox)再启用 Compton。若坚持尝试在 GNOME 会话中叠加 Compton,需先禁用 Mutter 的合成功能,但稳定性与兼容性不保证,出现问题应及时回退。
方案一 保持 GNOME 默认合成器 Mutter(推荐)
echo $XDG_SESSION_TYPE 应为 wayland 或 x11;ps aux | grep mutter 能看到 Mutter 合成进程在运行。方案二 使用不自带合成器的会话并启用 Compton(进阶)
sudo apt update && sudo apt install i3 compton(或 openbox)mkdir -p ~/.config && cp /etc/xdg/compton.conf ~/.config/compton.conf(若系统无该文件,可手动创建基础配置)compton --config ~/.config/compton.conf -b~/.config/autostart/compton.desktop[Desktop Entry]
Type=Application
Exec=compton --config ~/.config/compton.conf -b
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Compton
方案三 在 GNOME 会话中强行叠加 Compton(不推荐,仅作实验)
compton --config ~/.config/compton.conf -b~/.config/autostart/compton.desktop(见上文)Compton 配置与调优要点(适用于方案二/三)
~/.config/compton.conf):backend = "glx"
vsync = "true" # 减少撕裂
shadow = true
shadow-radius = 4
shadow-opacity = 0.5
fade = true
fade-delta = 30
unredirect-translucent-windows = true
backend 设为 glx,必要时关闭阴影或淡入淡出。glx-use-gl = true; glx-aa = "msaa"; glx-aa-depth = 4; glx-aa-samples = 4(对部分驱动/硬件有效)。fps-limit = 60(或匹配显示器刷新率)。compton --config ~/.config/compton.conf --log-level debugkillall compton 再启动,或使用自启项确保会话登录即启动。常见问题与排查
~/.config/compton.conf 语法(如引号、逗号、数组),用 compton --config ... -b 前台运行观察输出;必要时回退到上一个稳定配置。shadow、fade 等开关是否开启。shadow-exclude 对问题应用或窗口类进行排除,逐步定位。