温馨提示×

如何在Debian上调整Compton的透明度

小樊
36
2025-12-26 15:09:58
栏目: 智能运维

在 Debian 上调整 Compton 的透明度

一 安装与准备

  • Debian 上安装 Compton:
    • sudo apt update
    • sudo apt install compton
  • 若使用 Wayland 会话,Compton 无法工作,请改用 Xorg 会话或选择其他合成器(如 xcompmgr)。

二 通过配置文件设置透明度(推荐)

  • 创建或编辑配置文件:
    • mkdir -p ~/.config
    • nano ~/.config/compton.conf
  • 按应用或窗口设置透明度(opacity-rule 的数值为“不透明度百分比”,如 90 表示 90% 不透明,即 10% 透明):
    • opacity-rule = [ “90:class_g ‘Firefox’”, “90:name ‘Terminal’”, “100:class_g ‘Xephyr’” ]
  • 使配置生效:
    • 先结束旧进程:pkill compton
    • 启动:compton --config ~/.config/compton.conf
  • 可选:让 Compton 随会话自启
    • 例如在 i3 配置中加入:exec_always compton -b。

三 通过命令行快速调整

  • 后台启动并加载配置:compton -b --config ~/.config/compton.conf
  • 临时覆盖透明度(示例:全局不透明度 80%):compton -b -i 0.8
  • 使新参数立即生效:先 pkill compton,再执行带新参数的启动命令。

四 常见问题与进阶

  • 特定程序保持不透明(如 dmenu 覆盖层):
    • focus-exclude = “x 0 && y 0 && override_redirect true”
  • 忽略根窗口透明(避免桌面背景异常):
    • ignore_root = true
  • 性能与兼容性建议:
    • 渲染后端优先用 glx(若异常可改用 xrender):backend = “glx”
    • 某些桌面环境(如 GNOME)自带合成器,可能与 Compton 冲突,需禁用或调整其设置。

0