CentOS 上 Compton 设置指南
一 环境准备与安装
sudo yum install -y comptonsudo dnf install -y comptoncompton --version 或 which compton。若提示找不到命令,请检查是否已安装及 PATH。二 配置文件与基本参数
mkdir -p ~/.config && nano ~/.config/compton.conf。~/.config/compton.conf):# 渲染后端:优先 glx,兼容性不佳时改为 xrender
backend = "glx";
# 帧率上限
fps = 60;
# 垂直同步:减少撕裂;若遇到卡顿可尝试 false
vsync = true;
# 阴影
shadow = true;
shadow-radius = 12;
shadow-offset-x = 0;
shadow-offset-y = 8;
shadow-exclude = [
"name = 'Notification'",
"class_g = 'Conky'",
"class_g = 'Polybar'",
"_GTK_FRAME_EXTENTS@:c"
];
# 淡入淡出
fade = true;
fade-delta = 10;
# 不重定向全屏窗口(提升全屏游戏/视频性能)
unredir-if-possible = true;
# GLX 相关(遇到渲染问题时可切换尝试)
glx-no-stencil = true;
glx-copy-from-front = false;
# glx-use-dri3 = true; # 可选:若驱动/硬件支持可开启
compton -c ~/.config/compton.conf。如无报错且桌面特效恢复/增强,则配置基本正确。三 开机自启动与多显示器
nano ~/.config/systemd/user/compton.service[Unit]
Description=Compton Window Composer
After=graphical-session.target
[Service]
Type=simple
ExecStart=/usr/bin/compton --config %h/.config/compton.conf
Restart=on-failure
Environment=DISPLAY=:0
[Install]
WantedBy=default.target
systemctl --user daemon-reload
systemctl --user enable --now compton.service
xrandr --query 查看输出名称与连接状态。四 常见问题与优化建议
vsync 设为 true;若仍撕裂,可尝试切换 backend(glx/xrender)或关闭 unredir-if-possible 测试。shadow = false、fade = false),或降低 fps;全屏游戏/视频建议开启 unredir-if-possible = true。shadow-exclude、opacity-rule 等为指定应用(如 Firefox、Conky、Polybar)禁用阴影/透明度,减少重绘与伪影。blur-background = true)会提升观感但增加 GPU 负担;仅在显卡与驱动支持良好时使用。systemctl --user status compton.service 或 journalctl --user -u compton.service -bsystemctl --user restart compton.serviceglx 后端可能异常。