Linux下用 Compton 配置多屏显示
一 准备与基础配置
sudo apt-get update && sudo apt-get install comptonsudo yum install -y comptonmkdir -p ~/.config && nano ~/.config/compton.confbackend = "glx";glx-damage = true; damage = true;shadow = true/false;(多屏下为提升性能可关闭或精细排除)opacity-rule = [ "class_g ~ 'Firefox'", "class_g ~ 'Gnome-terminal'" ];shadow-exclude = [ "class_g ~ 'Firefox'", "class_g ~ 'Gnome-terminal'" ];compton -c ~/.config/compton.conf二 多显示器设置与显示命名
xrandr --queryxrandr --output HDMI-1 --auto --right-of eDP-1xrandr --output DP-1 --auto --right-of HDMI-1三 自启动与系统集成
~/.config/autostart/compton.desktop 中加入
[Desktop Entry]
Type=ApplicationExec=/usr/bin/compton -c ~/.config/compton.confHidden=false; NoDisplay=false; X-GNOME-Autostart-enabled=trueName=Compton; Comment=Compton Window Composernano ~/.config/systemd/user/compton.service[Unit]
Description=Compton CompositorAfter=graphical-session.target[Service]
ExecStart=/usr/bin/compton -c %h/.config/compton.confRestart=on-failure[Install]
WantedBy=graphical-session.targetsystemctl --user daemon-reloadsystemctl --user enable --now compton.service/etc/systemd/system/compton.service,并在 [Unit] 中使用 After=display-manager.service,然后 systemctl enable --now compton.service。四 多屏优化与常见问题
shadow = false;)或精简透明效果。vsync(开启可防撕裂,可能略降性能;关闭可降输入延迟)。shadow-exclude 与 opacity-rule 精确匹配。vsync = true; 或切换 backend;确保显卡驱动与 Compton 版本匹配。shadow-exclude 按 class/title/output 排除问题窗口或显示器。xrandr 确认连接与排列,再重启 Compton(或会话)。五 进阶规则示例
shadow-exclude = [ "output ~ '^(?!HDMI-1).*'" ];opacity-rule = [ "class_g ~ 'Firefox' && opacity 0.9", "class_g ~ 'Gnome-terminal' && opacity 0.95" ];glx-no-stencil = true; 并结合 shadow-exclude 或窗口规则按 output 细化。