Compton配置中透明度的实现方法
Compton作为Linux系统下的轻量级compositing window manager,通过OpenGL合成窗口实现透明效果。以下是具体的配置步骤及注意事项:
在大多数Linux发行版中,Compton可通过包管理器快速安装:
sudo apt update && sudo apt install comptonsudo dnf install comptonsudo pacman -S comptonCompton的默认配置文件路径为~/.config/compton.conf(若不存在需手动创建)。通过编辑该文件可永久设置透明度,关键参数如下:
[core] section中添加或修改alpha参数,取值范围为0.0(完全透明)到1.0(完全不透明),例如:[core]
alpha = 0.5 # 半透明效果
transparency-rule参数针对特定应用设置透明度,例如让Firefox和Chrome窗口透明:transparency-rule = ["class_g = 'Firefox' transparent", "class_g = 'Chrome' transparent"]
该规则表示匹配class_g(应用类名)为Firefox或Chrome的窗口,启用透明效果。若无需永久修改,可在启动Compton时通过命令行参数直接设置透明度:
compton -c ~/.config/compton.conf --alpha 0.5 &
其中--alpha参数后跟透明度值(0.0-1.0),&表示后台运行。
通过设置环境变量COMPTON_ALPHA,可在不修改配置文件的情况下调整透明度:
export COMPTON_ALPHA=0.5 # 在~/.bashrc或~/.zshrc中添加
compton -c ~/.config/compton.conf &
此方法无需每次启动Compton都指定参数,适合长期使用。
xcompmgr等其他复合器。