启用垂直同步的步骤
操作步骤
安装 compton(如未安装)
centos 7:sudo yum install compton;centos 8+/stream:sudo dnf install compton。
创建或编辑配置文件
配置文件路径:~/.config/compton.conf(若不存在则创建):
mkdir -p ~/.config
nano ~/.config/compton.conf。
写入启用 vsync 的配置
示例(使用 glx 后端并开启 vsync):
backend = “glx”
vsync = true
说明:backend 可选 “glx” 或 “xrender”,一般 glx 在支持 opengl 的显卡上更合适;vsync 设置为 true 即可开启垂直同步。
使配置生效
方式一(会话内重启):killall compton && compton &
方式二(开机自启,可选):创建 systemd 服务 /etc/systemd/system/compton.service,内容示例:
[unit]
description=compton window composer
after=display-manager.service
[service]
type=simple
execstart=/usr/bin/compton --config ~/.config/compton.conf
restart=on-failure
[install]
wantedby=multi-user.target
然后执行:sudo systemctl daemon-reload && sudo systemctl enable --now compton.service。
验证与常见问题
验证要点
重新登录或重启会话后,compton 应在后台运行;vsync 为全局开关,无需针对单个应用单独设置。若之前未使用配置文件启动,请通过 --config 指定你的配置文件路径。
常见问题与提示