在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以兼容舊硬件)。