Linux 中 Compton 配置技巧
一 基础安装与配置文件
sudo apt-get install compton;在 Arch Linux 使用 sudo pacman -S compton;在 Fedora/RHEL 使用 sudo dnf install compton。compton --config ~/.config/compton.conf -fkillall compton && compton --config ~/.config/compton.conf -f~/.config/systemd/user/compton.service[Unit]
Description=Compton Window Composer
After=xorg.target
[Service]
ExecStart=/usr/bin/compton --config %h/.config/compton.conf -b
Restart=on-failure
[Install]
WantedBy=default.target
systemctl --user daemon-reload && systemctl --user enable --now comptonps -e | grep compton 可确认进程是否存在。二 关键参数与推荐值
backend = "glx"(OpenGL,通常性能更好);兼容性不佳时可回退 xrender。vsync = true 可减少撕裂;若出现卡顿或输入延迟,可尝试 false。shadow = true;通过 [shadow] 细化半径、偏移与透明度。opacity-rule 为不同窗口设置透明度;ignore_root = true 可避免根窗口透明问题。blur-background = true,配合 [blur] 指定方法与强度。backend = "glx"
vsync = true
shadow = true
ignore_root = true
[shadow]
shadow-radius = 5
shadow-offset-x = 1
shadow-offset-y = 1
shadow-opacity = 0.3
[blur]
method = "gaussian"
size = 10
deviation = 5.0
opacity-rule = [
"90:name *? 'Firefox'",
"90:name *? 'Terminal'",
"100:class_g 'Xephyr'"
]
三 性能优化与常见问题
shadow = false、blur-background = false)。glx,必要时用 xrender)。vsync = true;若仍撕裂,结合驱动与显示器的自适应同步方案;若卡顿,尝试 vsync = false 并观察帧率变化。systemd 或 cpulimit 限制 Compton 资源占用。backend 或临时禁用部分特效排查。四 进阶用法与窗口规则
opacity-rule = [ "90:name *? 'Firefox'", "90:name *? 'Terminal'", "100:class_g 'Xephyr'" ]。shadow-exclude = [ "name 'Notification'", "class_g ? 'Dmenu'", "class_g ? 'Dunst'", "_NET_WM_STATE@:32a * '_NET_WM_STATE_HIDDEN'" ]。shader-file 指定片段着色器,实现个性化效果(进阶)。--config 指定不同配置文件,便于为不同场景(办公/游戏)快速切换。