centos

Compton在CentOS中的配置步骤

小樊
45
2025-08-24 23:46:08
栏目: 智能运维

以下是在CentOS中配置Compton的步骤:

  1. 安装Compton

    • 启用EPEL仓库(若未启用):
      sudo yum install epel-release
      
    • 安装Compton:
      sudo yum install compton  # CentOS 7及以下
      sudo dnf install compton  # CentOS 8及以上
      
  2. 创建配置文件

    • 若默认路径/.config/compton.conf不存在,手动创建:
      mkdir -p /.config
      nano /.config/compton.conf
      
    • 示例配置(关键参数说明):
      backend = "glx"       # 选择后端(glx/wayland,推荐glx提升性能)
      shadow = true         # 启用阴影
      shadow-exclude = [".*"] # 排除窗口阴影(如桌面环境窗口)
      opacity = 0.9         # 窗口透明度(0.0-1.0)
      vsync = true          # 启用垂直同步
      
  3. 启动Compton

    • 手动启动:
      compton --config /.config/compton.conf &
      
    • 设置开机自启:
      sudo nano /etc/systemd/system/compton.service
      
      添加以下内容:
      [Unit]
      Description=Compton Compositor
      After=graphical.target
      
      [Service]
      ExecStart=/usr/bin/compton --config /.config/compton.conf
      Restart=on-failure
      
      [Install]
      WantedBy=graphical.target
      
      然后执行:
      sudo systemctl enable compton
      sudo systemctl start compton
      
  4. 验证与优化

    • 检查日志(默认输出到终端,可配置log-file参数输出到文件):
      journalctl -u compton -f
      
    • 调整性能:关闭阴影/透明度、启用GPU加速(backend=glx)或限制CPU占用(cpulimit -l 50 -p $(pgrep compton))。

注意:CentOS默认使用X11,若需Wayland支持需额外配置显示服务器。

0
看了该问题的人还看了