在Linux系统中,Compton是一个轻量级的X11窗口合成器,它可以提供硬件加速的窗口渲染和透明度效果。以下是一些优化多显示器设置的技巧:
在基于Debian的系统上,使用以下命令安装Compton:
sudo apt-get update
sudo apt-get install compton
在主目录下创建一个名为 .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;
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\"" ];
在配置文件中添加 xrandr
命令的输出,以便Compton知道如何处理多个显示器。例如:
xrandr-output HDMI-1 eDP-1;
为了让Compton随系统启动自动运行,请创建Systemd服务文件 /etc/systemd/system/compton.service
,并添加以下内容:
[Unit]
Description=Compton Window Composer
After=xorg.service
[Service]
ExecStart=/usr/bin/compton --config /etc/compton.conf
RestartOnFailure=yes
[Install]
WantedBy=multi-user.target
保存后,运行以下命令启用并启动Compton服务:
sudo systemctl daemon-reload
sudo systemctl enable compton
sudo systemctl start compton
backend
设置为 glx
或 wayland
(而非 xrender
),通常能提升性能。vsync
设置为 true
或 false
,找到最佳平衡点。