温馨提示×

Compton配置与Xorg服务器如何配合

小樊
42
2025-12-29 19:47:45
栏目: 云计算

Compton 与 Xorg 的配合要点

  • Compton 是运行在 Xorg 之上的合成器,负责窗口合成、阴影、淡入淡出、透明度与不透明度规则等。它不参与会话选择,必须在 Xorg 会话中运行;在 Wayland 会话下不会生效。若使用 GNOME 等桌面,需在登录界面切换到 Xorg 会话后再启动 Compton。

安装与最小配置

  • 安装
    • Debian/Ubuntu 系:
      • sudo apt update && sudo apt install compton
  • 配置文件
    • 位置:~/.config/compton.conf(不存在可创建)
  • 最小可用示例
    • backend = “glx”;
    • vsync = true;
    • shadow = true;
    • fade = true;
    • opacity-rule = [ “90:class_g = ‘Firefox’”, “90:class_g = ‘Alacritty’” ];
    • shadow-exclude = [ “class_g ‘GtkMenu’”, “class_g ‘GtkDialog’”, “class_g ‘Notification’” ];
  • 启动
    • 手动:compton --config ~/.config/compton.conf
  • 说明
    • 有合适驱动时优先 glx(或部分构建的 egl),兼容性需求可选 xrender;不同版本选项可能略有差异,建议逐项启用并测试。

与 Xorg 的启动配合方式

  • 会话自启动(推荐)
    • 在桌面会话的“自启动/启动脚本”中加入:compton --config ~/.config/compton.conf
  • systemd 用户服务(避免权限与图形会话问题)
    • 创建:~/.config/systemd/user/compton.service
    • 内容:
      • [Unit]
        • Description=Compton Compositor
        • After=graphical-session.target
      • [Service]
        • ExecStart=/usr/bin/compton --config %h/.config/compton.conf
        • Restart=always
      • [Install]
        • WantedBy=default.target
    • 启用:
      • systemctl --user daemon-reload
      • systemctl --user enable --now compton.service
  • 临时热重载
    • pkill compton && compton --config ~/.config/compton.conf &
  • 多屏与显示管理
    • 多屏用 xrandr 配置输出(如:xrandr --output HDMI-1 --auto --right-of VGA-1),Compton 会自动适配已连接的 X11 屏幕;无需为双屏单独设置合成器参数。

常见配合问题与排查

  • 会话不匹配
    • Wayland 会话中 Compton 不生效;请在登录界面选择 Xorg 会话再测试。
  • 黑屏/崩溃/花屏
    • 先用最小化配置启动并在终端观察输出;逐项恢复选项定位问题。
    • 尝试切换 backend(glx/xrender),或调整 glx-damage / glx-fbo / glx-no-stencil 等 OpenGL 细节。
  • 撕裂或输入延迟
    • 开启 vsync 可减少撕裂但可能增加输入延迟;根据硬件与体验取舍。
  • 阴影异常
    • 完善 shadow-exclude,排除菜单、通知、Dock/面板等不需要阴影的窗口。
  • 版本差异
    • 某些选项(如 bg_blur / screen_edge_blur)仅在特定构建中提供;若配置项不存在,请确认所用版本与构建配置。

0