Linux下配置 Compton 透明度的实用指南
一 安装与准备
sudo apt update && sudo apt install comptonsudo dnf install comptonsudo pacman -S comptonmkdir -p ~/.config && nano ~/.config/compton.conf。二 配置文件方法与常用参数
opacity = 0.9;(表示整体 90% 不透明)。opacity-rule 精确匹配窗口并设置透明度,语法为 "透明度:条件"。示例:
opacity-rule = ["90:class_g 'Firefox'", "90:name 'Terminal'", "100:class_g 'Xephyr'"];(Firefox 与终端 90%,Xephyr 100%)。background-opacity(如 background-opacity = 0.8;)控制桌面背景的透明度。backend = "glx";(或 "xrender"),并根据需要开启 vsync = true;。fade = true; 获得更平滑的透明度过渡。blur-background = true; 并配置模糊参数(如 blur.method = "gaussian"; blur.size = 10; blur.deviation = 5.0;)。三 命令行快速设置
compton --config ~/.config/compton.conf(便于即时查看效果)。compton -b --config ~/.config/compton.conf。compton -b -i 0.5(等价于整体 50% 不透明)。compton -b -r 0.8(部分构建支持;若提示未知选项,请改用配置文件方式设置)。killall compton && compton &。四 自启动与验证
~/.config/autostart/compton.desktop,内容示例:[Desktop Entry]
Type=Application
Exec=compton
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Compton
五 常见问题与优化
backend 中优先使用 glx,并在显卡支持时启用相关加速选项(如 glx-use-dri3 等),在效果与性能间平衡。focus-exclude = "x 0 && y 0 && override_redirect true";,避免其被透明度影响。