Compton在CentOS上的设置指南
sudo yum update -y # CentOS 7及以下
sudo dnf update -y # CentOS 8及以上
yum:sudo yum install epel-release -y # 安装EPEL仓库(部分版本需此步骤)
sudo yum install compton -y
dnf:sudo dnf install compton -y
~/.config/compton.conf(用户级)或/etc/compton.conf(系统级)。若文件不存在,使用文本编辑器创建:mkdir -p ~/.config
nano ~/.config/compton.conf
backend = "glx" # 使用OpenGL加速(推荐),若兼容性问题可改为"xrender"
shadow = false # 禁用阴影(提升性能,若需要阴影可设为true)
opacity = false # 禁用窗口透明(减少资源占用)
ignore_glx_glitz = true # 忽略glitz库(解决部分显卡兼容性问题)
glx-no-stencil = true # 禁用模板缓冲(提升OpenGL性能)
glx-copy-from-front = true # 优化窗口移动时的渲染
shadow-exclude = [ # 排除不需要阴影的窗口(如Firefox)
"class='.*Firefox.*'",
"title='.*Firefox.*'"
]
vsync = true # 启用垂直同步(减少屏幕撕裂)
frame-rate = 30 # 限制帧率为30FPS(降低CPU占用)
注:若需更详细的配置选项,可通过
compton --help查看所有可用参数。
compton -c ~/.config/compton.conf
若需后台运行,添加&:compton -c ~/.config/compton.conf &
killall命令终止进程:killall compton
/etc/systemd/system/compton.service,内容如下:[Unit]
Description=Compton Window Composer
After=display-manager.service # 确保在显示管理器启动后运行
[Service]
ExecStart=/usr/bin/compton --config ~/.config/compton.conf
Restart=on-failure # 失败时自动重启
RestartSec=5s
[Install]
WantedBy=multi-user.target # 多用户模式下启动
sudo systemctl daemon-reload # 重新加载Systemd配置
sudo systemctl enable compton # 设置开机自启动
sudo systemctl start compton # 立即启动服务
systemctl status compton
若显示active (running),则表示服务已成功启动。backend改为xrender(禁用OpenGL),或调整frame-rate降低帧率。shadow、opacity)。GLX扩展未找到,需安装显卡驱动(如NVIDIA专有驱动),并确认backend设置为glx。/etc/compton.conf),需确保服务文件中的ExecStart路径正确;若使用用户级配置,需通过--config指定路径。通过以上步骤,即可在CentOS上完成Compton的安装、配置与开机自启动,提升桌面环境的视觉效果与性能。