Linux Compton支持多屏显示
Compton作为轻量级X11窗口合成器,原生支持多显示器配置,可通过合理设置实现多屏显示效果。
通过包管理器安装Compton(以Debian/Ubuntu为例):
sudo apt-get update && sudo apt-get install compton
其他发行版(如Fedora、CentOS)可替换为对应包管理器命令。
Compton依赖xrandr管理显示器,首先查看当前显示器信息:
xrandr --query
假设输出包含HDMI-1(外接屏)、eDP-1(内置屏),可将外接屏设置为内置屏右侧扩展:
xrandr --output HDMI-1 --auto --right-of eDP-1
此命令会自动调整分辨率并将两屏拼接,确保多屏物理连接正确。
Compton的主配置文件通常位于~/.config/compton.conf(若不存在则创建),需添加/修改以下关键选项:
glx后端以提升多屏渲染性能;shadow-exclude排除桌面、终端等窗口的阴影,防止多屏边缘显示异常;opacity-rule调整窗口透明度(可选)。示例配置片段:
backend "glx" # 使用GLX硬件加速
glx-no-stencil false
glx-copy-from-front true
glx-hardware true
damage true
# 排除桌面、终端、Firefox的阴影
shadow-exclude [
"class_g \"Desktop\"",
"class_g \"Gnome-terminal\"",
"class_g \"Firefox\""
]
# 设置桌面透明度规则(可选)
opacity-rule [
"class_g \"Desktop\" A",
"class_g \"Gnome-terminal\" 0.8"
]
保存配置文件后,可通过compton -c ~/.config/compton.conf手动启动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 enable compton.service启用服务,重启后Compton会自动启动。xrandr布局或Compton的xrandr-args选项(如--xrandr-screen=0指定屏幕);