CentOS 上配置 Compton 的完整步骤
一 环境准备与安装
sudo yum update -ysudo yum install -y compton(或 sudo dnf install -y compton)二 配置文件与关键参数
mkdir -p ~/.config && nano ~/.config/compton.conf# 合成后端:优先 GLX;若异常可尝试 xrender
backend = "glx"
# 帧率上限(与显示器刷新率匹配更流畅)
fps = 60
# 垂直同步(减少撕裂;若输入延迟敏感可尝试 false)
vsync = true
# 阴影
shadow = true
shadow-radius = 12
shadow-offset-x = -15
shadow-offset-y = -15
shadow-exclude = [
"name = 'Notification'",
"class_g = 'Conky'",
"class_g = 'Polybar'",
"_NET_WM_WINDOW_TYPE@:a = 'dock'"
]
# 淡入淡出动画
fade = true
fade-delta = 10
# 未重定向直绘(提升全屏游戏性能;出现撕裂可改为 false)
unredirected-fullscreen = true
# 透明度规则(示例)
opacity-rule = [
"90:class_g = 'Firefox'",
"90:class_g = 'Terminal'",
"100:class_g = 'Xephyr'"
]
# 背景模糊(可选,性能开销较大)
# blur-background = true
# blur-kern = "7x7box"
三 启动方式与自启动
compton -c ~/.config/compton.confcompton --config ~/.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 /home/your-username/.config/compton.conf
Restart=on-failure
Environment=DISPLAY=:0
[Install]
WantedBy=default.target
systemctl --user daemon-reloadsystemctl --user enable --now compton.servicesudo nano /etc/systemd/system/compton.service[Unit]
Description=Compton Window Composer
After=display-manager.service
[Service]
Type=simple
ExecStart=/usr/bin/compton --config /home/your-username/.config/compton.conf
Restart=on-failure
User=your-username
Environment=DISPLAY=:0
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reloadsudo systemctl enable --now compton.service四 验证与常见问题
pgrep -x comptonjournalctl --user -u compton.service -b(用户服务)或 sudo journalctl -u compton.service -b(系统服务)xrandr --query 检查输出名,必要时用 xrandr --output <NAME> --auto --right-of <OTHER> 排布;Compton 会自动处理多屏合成。