在 CentOS 上使用 Compton 提升显示效果
一 安装与准备
- 在 CentOS 7/8/Stream 上,先启用 EPEL 仓库,再用包管理器安装 Compton:
- 安装 EPEL:sudo yum install -y epel-release(或 dnf install -y epel-release)
- 安装 Compton:sudo yum install -y compton(或 dnf install -y compton)
- 若系统仓库暂未提供,可先启用 EPEL 后再安装,或考虑使用其他合成器(如 picom)作为替代。
二 配置要点与示例
三 启动与自启动
- 手动启动(测试用):compton --config ~/.config/compton.conf
- 热重载:killall compton && compton --config ~/.config/compton.conf
- 开机自启动(推荐用户级 systemd 服务):
- 创建服务文件:sudo nano /etc/systemd/system/compton.service
- 写入以下内容(注意将 ExecStart 路径替换为 which compton 的实际路径,如 /usr/bin/compton):
[Unit]
Description=Compton Window Composer
After=display-manager.service
[Service]
Type=simple
ExecStart=/usr/bin/compton --config /home/你的用户名/.config/compton.conf
Restart=always
RestartSec=3
[Install]
WantedBy=graphical.target
- 启用并启动:
- sudo systemctl daemon-reload
- sudo systemctl enable --now compton
- 若使用登录会话自启动(如 ~/.xprofile 或桌面会话的“启动程序”),请确保只启动一个 Compton 实例,避免冲突。
四 验证与常见问题
- 验证要点:
- 观察窗口移动、最小化/最大化、透明度与阴影/模糊是否生效。
- 检查运行状态:systemctl --user status compton(用户级)或 systemctl status compton(系统级)。
- 查看日志定位问题:compton --config ~/.config/compton.conf 2> /var/log/compton.log,随后 cat /var/log/compton.log。
- 常见问题与处理:
- 屏幕撕裂:将 vsync 设为 true;若仍撕裂,尝试关闭并重试,或结合 unredirect = false 观察。
- 性能不佳:关闭 shadow 与 blur,或将 backend 调整为 glx;必要时降低模糊半径与透明度规则数量。
- 全屏游戏卡顿:保持 unredirect = false,避免不必要的合成重定向;若仍受影响,可临时停止 Compton 测试。
- 多显示器:先通过 xrandr --query 确认输出名与布局,再按需调整 Compton 配置;多屏下优先使用 glx 后端以获得更一致的体验。