温馨提示×

Debian Compton配置中多显示器支持

小樊
43
2026-01-05 09:15:06
栏目: 智能运维

Debian 下 Compton 多显示器配置指南

快速要点

  • Compton 原生支持 多显示器,无需特殊开关;关键在于正确设置显示器的连接与相对位置,并让合成器在会话启动时运行。
  • 使用 xrandr 确认并配置输出名称与布局(如 HDMI-1DP-1eDP-1),确保扩展/镜像等模式符合预期。
  • 通过配置文件启用合适的 backend(如 glxxrender)与必要的渲染特性,按需设置阴影、透明度与排除规则。
  • 将 Compton 加入会话的自启动(窗口管理器启动脚本或 systemd 用户服务),确保登录后自动合成。

安装与准备

  • 安装 Compton 及常用工具:
    • sudo apt update && sudo apt install compton x11-xserver-utils wmctrl -y
  • 确认显示器名称与布局:
    • xrandr
    • 示例(扩展模式):xrandr --output HDMI-1 --auto --right-of eDP-1;xrandr --output DP-1 --auto --right-of HDMI-1
  • 建议先关闭其他合成器(如已有窗口管理器内置合成),避免冲突。

配置文件要点

  • 创建或编辑配置文件:~/.config/compton.conf
  • 示例(多显示器常用起步配置,含阴影与透明度规则):
    • backend “glx”
    • glx-no-stencil false
    • glx-copy-from-front true
    • glx-shape true
    • glx-fbconfig false
    • glx-hardware true
    • glx-damage true
    • damage true
    • shadow true
    • opacity-rule [ “class_g "Desktop" A”, “class_g "Gnome-terminal" A”, “class_g "Firefox" A” ]
    • shadow-exclude [ “class_g "Desktop"”, “class_g "Gnome-terminal"”, “class_g "Firefox"” ]
  • 说明:
    • 多显示器无需在配置中逐个列出输出名称;Compton 会自动枚举 Xinerama/XRandR 输出。
    • 若出现性能或渲染问题,可尝试将 backend 调整为 “xrender” 并相应增减特性。

启动与自启动

  • 手动测试:
    • compton -c ~/.config/compton.conf
  • 开机自启动方式一(会话启动脚本,适用于 Openbox 等):
    • 将 compton 启动命令加入窗口管理器的自启动脚本(如 Openbox 的 autostart)。
  • 开机自启动方式二(systemd 用户服务,推荐):
    • 创建服务文件:/etc/systemd/system/compton.service
    • 内容示例:
      • [Unit]
        • Description=Compton Compositor
        • After=display-manager.service
      • [Service]
        • ExecStart=/usr/bin/compton -c /home/你的用户名/.config/compton.conf
        • Restart=on-failure
      • [Install]
        • WantedBy=multi-user.target
    • 启用并启动:
      • sudo systemctl enable compton.service
      • sudo systemctl start compton.service
      • 验证:systemctl status compton.service

常见问题与排查

  • 窗口阴影跨屏异常或性能不佳:
    • 调整 backend 为 glx/xrender,开启/关闭 glx-damageshadow 进行对比测试;必要时精简阴影与透明度规则。
  • 合成器未生效或与其他合成器冲突:
    • 确认仅保留一个合成器运行;登录会话后检查进程(如 pgrep compton),必要时重启会话或系统。
  • 显示器热插拔后未正确合成:
    • 重新执行 xrandr 调整布局后,重启 Compton(systemctl restart compton 或重登会话)。

0