CentOS 下使用 Compton 配置多显示器
一 核心要点
二 安装与准备
sudo yum install -y comptonsudo dnf install -y comptonxrandr --query 查看输出名称(如 eDP-1、HDMI-1、DP-1)与当前模式。xrandr --output HDMI-1 --auto --right-of eDP-1xrandr --output DP-1 --auto --right-of HDMI-1三 配置文件与关键参数
mkdir -p ~/.config && nano ~/.config/compton.conf# 渲染后端:优先 glx,若出现异常可尝试 xrender
backend = "glx"
# 启用/禁用阴影(多屏下可按需关闭以提升性能)
shadow = true
shadow-exclude = [
"name = 'Conky'",
"class_g = 'Polybar'",
"class_g = 'Xfce4-notifyd'"
]
# 窗口透明度与规则
opacity-rule = [
"90:class_g = 'Xfce4-terminal'",
"85:class_g = 'Firefox'"
]
# 避免撕裂(与驱动/应用兼容性有关,必要时可改为 false)
vsync = true
# 模糊与特效(多屏下较耗资源,可按需关闭)
blur-background = false
blur-kern = "3x3box"
# 其他稳定性项
glx-no-stencil = true
glx-copy-from-front = false
四 启动与自启动
compton -c ~/.config/compton.confnano ~/.config/systemd/user/compton.service[Unit]
Description=Compton Window Composer
After=graphical-session.target
[Service]
ExecStart=/usr/bin/compton -c %h/.config/compton.conf
Restart=on-failure
Environment=DISPLAY=:0
[Install]
WantedBy=graphical-session.target
systemctl --user daemon-reloadsystemctl --user enable --now compton.servicesystemctl --user status compton.service 查看状态。五 常见问题与排查
backend 与 vsync;尝试切换 glx/xrender,或将 vsync 设为 false 测试。blur-background,精简 shadow-exclude 列表,减少阴影覆盖的窗口类型。xrandr 布局正确;重启 Compton;必要时在 shadow-exclude/opacity-rule 中为该屏幕上的特定应用添加排除或规则。enable --now;登录会话后再检查状态。systemctl status 与 journalctl --user -u compton.service 查看运行日志与回溯信息。