温馨提示×

Compton配置文件如何编写才能生效

小樊
55
2025-08-19 06:18:58
栏目: 编程语言

Compton配置文件编写及生效步骤如下:

  1. 定位/创建配置文件

    • 默认路径:用户主目录下的.config/compton.conf(如~/.config/compton.conf)。
    • 若不存在,手动创建:
      mkdir -p ~/.config
      touch ~/.config/compton.conf
      
  2. 编辑配置文件

    • 使用文本编辑器(如nanovim)修改,注意YAML格式缩进
    • 常用配置示例:
      backend: "glx"  # 合成后端,可选x11/wayland/glx
      shadow: true    # 启用阴影
      shadow-exclude:  # 排除特定窗口阴影(支持类名、正则)
        - "class_g = 'Firefox'"
        - "class_g = 'Thunderbird'"
      opacity: 0.9    # 全局透明度(0-1)
      blur-radius: 5  # 模糊半径
      glx-no-stencil: true  # 禁用模板缓冲区(提升性能)
      
  3. 保存并重启生效

    • 保存文件后,重启Compton:
      # 手动重启(非系统服务)
      pkill compton
      compton --config ~/.config/compton.conf &
      
      # 若为系统服务(需提前配置)
      sudo systemctl restart compton
      

注意事项

  • 配置文件语法错误可能导致Compton无法启动,建议通过compton --config /path/to/config.conf --debug调试。
  • 部分选项(如backend)需根据系统环境选择(如Wayland环境需设为wayland)。
  • 更多选项可参考Compton官方文档man compton

0