Compton配置中实现透明度的步骤
首先需要确保系统已安装Compton。根据发行版选择对应命令:
sudo apt update && sudo apt install comptonsudo dnf install comptonsudo pacman -S comptonCompton的配置文件通常位于~/.config/compton.conf(若不存在则手动创建)。通过修改以下参数实现透明度控制:
在配置文件中添加或修改alpha参数,直接控制整体透明度:
[core]alpha = 0.5# 范围0.0(完全透明)~1.0(完全不透明),0.5表示半透明此参数是全局透明度设置,影响所有窗口的基础透明效果。
通过transparency-rule参数针对特定应用设置透明度,提升定制性:
transparency-rule = ["class_g = 'Firefox' transparent",# Firefox窗口透明"class_g = 'Chrome' transparent", # Chrome窗口透明"class_g = 'Terminal' transparent"# 终端窗口透明]将class_g替换为目标应用的窗口类名(可通过xprop命令获取,如xprop | grep WM_CLASS)。
shadow-exclude = [".*"]# 排除所有窗口的阴影(按需调整)glx(性能更好,推荐)或x11(兼容性更好):backend = "glx"frame-rate = 60)。compton -c ~/.config/compton.conf &sudo nano /etc/systemd/system/compton.service添加以下内容:[Unit]Description=Compton CompositorAfter=display-manager.service[Service]ExecStart=/usr/bin/compton --config ~/.config/compton.confRestart=always[Install]WantedBy=multi-user.target启用并启动服务:sudo systemctl enable comptonsudo systemctl start comptoncompton -c ~/.config/compton.conf --alpha 0.6 &COMPTON_ALPHA变量设置透明度(无需每次指定参数):export COMPTON_ALPHA=0.6compton -c ~/.config/compton.conf &将上述命令添加到~/.bashrc或~/.zshrc中,可永久生效。xcompmgr或其他Wayland兼容复合器。frame-rate值或简化阴影设置。