linux

如何使用Compton进行多屏显示

小樊
38
2025-12-23 23:16:38
栏目: 编程语言

Compton多屏显示使用指南

核心要点

快速上手步骤

  1. 确认显示器名称
    运行:xrandr --query,查看已连接输出名称(如 eDP-1HDMI-1DP-1)及当前状态。
  2. 设置多屏布局(扩展/镜像)
    例如以笔记本 eDP-1 为主屏,向右扩展:
    • xrandr --output HDMI-1 --auto --right-of eDP-1
    • xrandr --output DP-1 --auto --right-of HDMI-1
  3. 安装并准备 Compton
    • Debian/Ubuntu:sudo apt-get update && sudo apt-get install compton
    • RHEL/CentOS:sudo yum install -y compton
  4. 创建基础配置文件
    mkdir -p ~/.config && nano ~/.config/compton.conf
  5. 启动 Compton 测试
    compton -c ~/.config/compton.conf
  6. 设置开机自启(可选)
    将启动命令加入窗口管理器的自启动脚本,或使用 systemd 用户服务(见下文示例)。

示例配置文件

# 选择合成后端(多屏通常选 glx)
backend = "glx";

# 帧率限制(按显示器刷新率设置,常见 60/120)
fps-limit = 60;

# 阴影:全局开启,排除不需要的窗口类
shadow = true;
shadow-radius = 5;
shadow-opacity = 0.5;
shadow-exclude = [
  "class_g = 'gnome-terminal'",
  "class_g = 'konsole'",
  "class_g = 'xterm'",
  "class_g = 'Firefox'"
];

# 合成与渲染细节
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 = 'Gnome-terminal' A",
  "class_g = 'Firefox' A"
];

自启动与验证

[Unit]
Description=Compton Compositor
After=graphical-session.target

[Service]
ExecStart=/usr/bin/compton -c /home/你的用户名/.config/compton.conf
Restart=on-failure
Environment=XDG_RUNTIME_DIR=/run/user/1000

[Install]
WantedBy=default.target
  1. 启用并启动:
    systemctl --user daemon-reload
    systemctl --user enable --now compton.service

0
看了该问题的人还看了