Compton(现分支为Picom)是一款轻量级X11合成窗口管理器,能显著提升Linux桌面视觉效果和性能。以下是详细配置指南:
# Arch系
sudo pacman -S picom
# Debian/Ubuntu系
sudo apt install picom
# 手动编译最新版(推荐)
git clone https://github.com/yshui/picom
cd picom && meson setup --buildtype=release build
ninja -C build && sudo ninja -C build install
# 启用VSync防撕裂
vsync = true;
use-damage = true;
# 阴影设置
shadow = true;
shadow-radius = 12;
shadow-opacity = 0.75;
shadow-offset-x = -15;
shadow-offset-y = -12;
# 透明度设置
inactive-opacity = 0.9;
active-opacity = 1.0;
frame-opacity = 0.7;
inactive-opacity-override = false;
backend = "glx";
glx-no-stencil = true;
glx-no-rebind-pixmap = true;
xrender-sync-fence = true;
# 禁用终端透明
opacity-rule = [
"90:class_g = 'Alacritty' && focused",
"70:class_g = 'Alacritty' && !focused",
"100:class_g = 'Firefox'"
];
# 无阴影窗口列表
shadow-exclude = [
"class_g = 'Dmenu'",
"name *= 'Notification'",
"window_type = 'dropdown_menu'"
];
# NVIDIA用户专用设置
vsync = true;
backend = "glx";
glx-swap-method = "buffer-age"; # 或试 "exchange"
# 使用DRI_PRIME=1运行
DRI_PRIME=1 picom --config ~/.config/picom/picom.conf -b
# 每2小时自动重启(cron定时任务)
[auto-restart]
enable = true;
interval = 7200;
blur: {
method = "kawase";
strength = 8;
background = true;
background-frame = true;
background-fixed = true;
}
# 窗口动画(需配合animations分支)
animations = true;
animation-window-mass = 0.5;
animation-stiffness = 200;
picom --config ~/.config/picom/picom.conf -b --log-level=DEBUG
watch -n 0.5 "cat /proc/$(pidof picom)/status | grep -i vm"
[Unit]
Description=Picom compositor
[Service]
ExecStart=/usr/bin/picom --experimental-backends -b
Restart=always
[Install]
WantedBy=default.target
启用服务:systemctl --user enable --now picom
提示:配置修改后需用
pkill -USR1 picom
重载配置。建议从官方示例配置开始,逐步添加自定义规则。