centos 上 compton 的多显示器支持
支持,compton 作为 x11 的窗口合成器,原生支持多显示器。在 centos 上只需先用 xrandr 正确布局各显示器,再启动 compton 即可,无需特殊的多屏选项。常见做法是先用 xrandr 设置扩展模式,例如将 hdmi-1 放在 edp-1 右侧、dp-1 放在 hdmi-1 右侧,然后启动 compton 使其作用于所有已连接的输出。
快速配置步骤
- 安装 compton:sudo yum install -y compton(或 sudo dnf install compton)。
- 用 xrandr 查看并布局显示器:xrandr --query;示例布局:xrandr --output hdmi-1 --auto --right-of edp-1;xrandr --output dp-1 --auto --right-of hdmi-1。
- 启动 compton:compton -c ~/.config/compton.conf(配置文件可按需定制)。
- 开机自启动(可选):创建 /etc/systemd/system/compton.service,示例:
[unit] description=compton compositor;after=display-manager.service
[service] execstart=/usr/bin/compton -c ~/.config/compton.conf;restart=on-failure
[install] wantedby=multi-user.target
然后执行:sudo systemctl daemon-reload && sudo systemctl enable --now compton。
多显示器配置要点
- 使用 opengl 后端通常体验更好:backend = “glx”;必要时可开启 vsync、设置 fps-limit 等以获得更稳定的多屏渲染与帧率。
- 多屏阴影与性能:可按需设置 shadow-exclude 规则,减少跨屏阴影、终端等窗口的阴影开销。
- 配置文件路径与生效:常用路径为 ~/.config/compton.conf;修改后需重启 compton 生效(systemctl restart compton 或重登会话)。
常见问题与排查
- 显示器未扩展而是镜像:先用 xrandr 正确设置 --right-of/–left-of/–above 等位置关系,再启动 compton。
- 合成器未生效或被覆盖:确认会话类型(x11),避免与桌面自带的合成器冲突;必要时在登录会话的启动脚本中确保只启动一个合成器。
- 查看运行状态与日志:使用 systemctl status compton 检查是否运行;如需详细日志,可在 compton 启动参数中加入 --log-file /path/compton.log 并适当提高日志级别以便排查。