centos

如何用Compton改善CentOS的图形界面

小樊
41
2025-09-06 00:25:07
栏目: 智能运维

  1. 安装Compton

    • 更新系统并安装依赖:
      sudo yum update -y
      sudo yum install -y epel-release cmake libX11-devel mesa-libGL
    • 从源码编译安装(推荐最新版):
      git clone https://github.com/compton/compton.git
      cd compton && mkdir build && cmake .. && make && sudo make install
  2. 配置Compton

    • 编辑配置文件 ~/.config/compton.conf,常用优化参数:
      backend = "glx"  # 选择GLX后端提升性能
      shadow = true    # 启用阴影(可自定义排除区域)
      opacity = 0.9    # 窗口透明度(0-1)
      vsync = true     # 启用垂直同步减少撕裂
      cache-size = 1024 # 缓存大小(MB),降低延迟
      blur = true      # 启用背景模糊
      
    • 排除不需要特效的窗口(如桌面、通知栏):
      shadow-exclude = ["class_g 'Xfce4-Panel'", "name 'Notification'"]
  3. 启动与自动运行

    • 手动启动:
      compton --config ~/.config/compton.conf
    • 设置为系统服务(开机自启):
      创建服务文件 /etc/systemd/system/compton.service
      [Unit]
      Description=Compton Compositor
      After=display-manager.service
      [Service]
      ExecStart=/usr/local/bin/compton --config ~/.config/compton.conf
      Restart=always
      [Install]
      WantedBy=multi-user.target
      
      启用并启动服务:
      sudo systemctl enable compton && sudo systemctl start compton
  4. 优化与调试

    • 监控性能:使用 glxgears 测试帧率,调整 vsynccache-size
    • 禁用冲突功能:若与桌面环境特效冲突,可尝试禁用 fadeshadow
    • 日志排查:添加 -o /tmp/compton.log 参数查看运行状态。

注意:CentOS默认使用X11,若使用Wayland需确认Compton兼容性,部分参数需调整。建议根据硬件配置(如集成显卡/独显)选择后端(glx/xrender)。

0
看了该问题的人还看了