Debian Compton多显示器环境配置指南
首先确保系统已安装Compton。若未安装,可通过以下命令完成安装:
sudo apt update
sudo apt install compton
Compton的默认配置文件位于用户主目录下的.config/compton.conf(若不存在,可手动创建)。使用文本编辑器(如nano)打开配置文件:
nano ~/.config/compton.conf
Compton支持通过xrandr集成或直接指定显示器参数两种方式适配多显示器环境:
首先,使用xrandr命令查看当前显示器配置(如名称、分辨率、位置):
xrandr --query
输出示例会显示类似HDMI-1、DP-1、eDP-1的显示器名称及连接状态。
接着,在compton.conf中添加xrandr-output指令,关联显示器的主从关系(以eDP-1为主屏,HDMI-1、DP-1为副屏为例):
xrandr-output "HDMI-1" "eDP-1";
xrandr-output "DP-1" "HDMI-1";
此配置会让Compton自动适配xrandr的多显示器布局(如扩展、复制模式)。
若需更精细的控制,可在compton.conf中为每个显示器单独设置参数(以两个显示器HDMI-1、VGA-1为例):
screen0 {
output = "HDMI-1";
position = "left"; # 相对位置(left/right/top/bottom)
transform = "normal"; # 变换方式(normal/90/180/270/flip_x/flip_y)
scale = 1.0; # 缩放比例(适配高DPI显示器)
}
screen1 {
output = "VGA-1";
position = "right"; # 与screen0的相对位置
transform = "normal";
scale = 1.0;
}
根据需求调整以下参数,提升多显示器体验:
shadow-exclude = [
"class_g \"Desktop\"",
"class_g \"Gnome-terminal\"",
"class_g \"Firefox\"",
"name = \"desktop_window\""
];
blur-background = true;
blur-kern = "3x3box"; # 模糊核类型(可选:3x3box/5x5box/gaussian)
vsync = true;
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
sudo systemctl start compton.service
systemctl status compton.service,确认Compton处于active (running)状态。~/.cache/compton.log)排查错误信息。nvidia-driver并配置Xorg)。xrandr命令并调整compton.conf中的xrandr-output设置。