在Debian上启用Compton的步骤
Compton的安装方式分为APT(官方源)和Snap两种,推荐优先使用APT(更稳定,适合大多数Debian版本):
sudo apt update && sudo apt install compton -y
sudo apt install snapd -y # 若未安装Snapd
sudo snap install compton --classic # 安装Compton(--classic模式允许无沙盒访问)
Compton的默认配置文件路径为~/.config/compton.conf(用户级配置,仅影响当前用户),若文件不存在可手动创建:
mkdir -p ~/.config # 若.config目录不存在
nano ~/.config/compton.conf # 编辑配置文件
常用配置选项(根据需求调整):
vsync = trueshadow = trueopacity范围0-1,1为不透明):opacity = 0.9ignore_root = true[blur]
method = gaussian # 模糊算法(gaussian/box)
size = 10 # 模糊半径
deviation = 5.0 # 模糊强度
[opacity-rule]
90:class_g = 'Firefox' # Firefox窗口透明度设为90%
100:class_g = 'Xephyr' # Xephyr窗口完全不透明
--config):compton --config ~/.config/compton.conf &
(&表示后台运行,避免阻塞终端)sudo nano /etc/systemd/system/compton.service
写入以下内容(根据安装方式调整ExecStart路径):[Unit]
Description=Compton Window Compositor
After=graphical.target # 确保在图形界面启动后运行
[Service]
ExecStart=/usr/bin/compton --config /home/你的用户名/.config/compton.conf # 替换为实际路径
Restart=always # 崩溃后自动重启
User=你的用户名 # 替换为实际用户名
[Install]
WantedBy=multi-user.target # 多用户模式下启动
保存后执行以下命令启用并启动服务:sudo systemctl daemon-reload # 重新加载systemd配置
sudo systemctl enable compton # 设置开机自启
sudo systemctl start compton # 立即启动
systemctl status compton # 查看服务状态(若显示“active (running)”则为正常)
cat ~/.cache/compton.log # 默认日志路径
sudo systemctl restart compton
x11-xserver-utils);若使用Snap,需确保Snapd服务正常运行(sudo systemctl status snapd)。backend(如改为xrender以兼容旧硬件)。