Ubuntu 下 Compton 配置教程
一 安装与快速启动
sudo apt update
sudo apt install compton
compton -b & # -b 后台运行
ps -e | grep compton # 检查是否已运行
二 配置文件与基础参数
mkdir -p ~/.config
nano ~/.config/compton.conf
backend = "glx"
vsync = true
shadow = true
fade = true
unredirect-translucent-windows = true
[shadow]
shadow-radius = 5
shadow-offset-x = 1
shadow-offset-y = 1
shadow-opacity = 0.3
[opacity-rule]
"90:class_g 'Firefox'"
"90:name 'Terminal'"
"100:class_g 'Xephyr'"
三 桌面环境集成与自启动
~/.xinitrc、~/.config/openbox/autostart 或 i3 配置)中加入:exec compton -b --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 %h/.config/compton.conf -b
Restart=on-failure
[Install]
WantedBy=graphical-session.target
systemctl --user daemon-reload
systemctl --user enable --now compton.service
sudo nano /etc/systemd/system/compton.service
写入示例:[Unit]
Description=Compton Window Composer
After=display-manager.service
[Service]
Type=simple
ExecStart=/usr/bin/compton -b --config /etc/xdg/compton.conf
Restart=always
[Install]
WantedBy=multi-user.target
启用:sudo systemctl daemon-reload
sudo systemctl enable --now compton.service
killall compton
compton -b --config ~/.config/compton.conf &
# 或使用 systemd:systemctl --user restart compton.service
四 常见问题与性能优化
[opacity-rule]
"90:class_g 'Firefox'"
"90:name 'Terminal'"