debian

怎样在Debian上使用Compton进行多屏显示

小樊
42
2025-07-18 01:45:08
栏目: 智能运维

在Debian上使用Compton进行多屏显示,可以按照以下步骤进行配置:

安装Compton

首先,确保你的Debian系统已经更新,并且安装了Compton。你可以使用以下命令来安装Compton:

sudo apt update
sudo apt install compton

配置Compton

  1. 创建或编辑Compton配置文件: Compton的配置文件通常位于~/.config/compton.conf。如果该文件不存在,你可以手动创建一个。

    mkdir -p ~/.config
    touch ~/.config/compton.conf
    
  2. 配置多显示器: 在~/.config/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";
    

    这里的HDMI-1eDP-1是你显示器的名称,你可以通过运行xrandr命令来查看你的显示器名称。

  3. 启动Compton: 配置文件准备好后,你可以通过命令行运行Compton:

    compton -c ~/.config/compton.conf
    
  4. 设置Compton开机自启动(可选): 如果你想让Compton在系统启动时自动运行,可以创建一个systemd服务。

    sudo nano /etc/systemd/system/compton.service
    

    在文件中添加以下内容:

    [Unit]
    Description=Compton Compositor
    After=display-manager.service
    
    [Service]
    ExecStart=/usr/bin/compton -c ~/.config/compton.conf
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    

    保存并退出编辑器,然后启用并启动服务:

    sudo systemctl enable compton.service
    sudo systemctl start compton.service
    

验证配置

确保Compton正在运行并且多显示器配置正确。你可以通过以下命令检查Compton的状态:

systemctl status compton.service

如果一切正常,你应该能够看到Compton正在运行,并且你的多显示器设置应该已经生效。

0
看了该问题的人还看了