一、安裝Compton
Compton是一款輕量級窗口合成管理器,能有效提升Linux桌面視覺效果與性能。安裝前需確認系統已更新,再根據發行版選擇對應命令:
sudo apt-get install compton
sudo pacman -S compton
sudo dnf install compton
二、配置Compton
Compton的配置文件通常位于~/.config/compton.conf
(用戶級)或/etc/xdg/compton.conf
(系統級)。若文件不存在,可手動創建。以下是關鍵參數說明及優化建議:
glx
(支持GPU加速,提升性能)或wayland
(適配現代桌面環境),避免使用xrender
(性能較差)。true
可減少畫面撕裂,但可能增加輸入延遲;若追求流暢度,可設為false
。false
可禁用(節省GPU資源),若需保留陰影,可調整為shadow = true
并結合shadow-radius
(陰影半徑)、shadow-offset-x/y
(陰影偏移)優化。1.0
(完全不透明)可禁用透明效果(提升性能);若需透明,建議設為0.8-0.9
(平衡視覺與性能)。true
可避免桌面背景透明導致的顯示問題(如壁紙不顯示)。true
可啟用(需GPU支持),提升窗口層級感;若性能不足,設為false
。true
可增強視覺沉浸感,但對性能有一定消耗。true
可啟用(提升交互體驗);若追求極致性能,設為false
。0.05
),值越大動畫越快(如0.1
)。i3
、sway
),確保Compton與窗口管理器無縫協作(避免焦點、工作區切換問題)。opacity-rule = [
"CLASS = 'Firefox', opacity = 0.9;", // Firefox瀏覽器透明度90%
"CLASS = 'GIMP', opacity = 0.8;", // GIMP圖像編輯器透明度80%
"CLASS = 'vlc', opacity = 0.7;" // VLC播放器透明度70%
];
這樣可降低高頻使用窗口的資源占用,同時保持桌面整體美觀。三、性能優化技巧
shadow = false
)、透明(opacity = 1.0
)、模糊(bg_blur = false
)等特效,減少GPU負載。glx
(GPU加速)或wayland
(現代桌面),避免xrender
(CPU渲染,性能差)。vsync = true
可減少撕裂;若追求流暢度(如游戲場景),設為false
。cpulimit
工具限制Compton的CPU使用率(如限制到50%):cpulimit -l 50 -p $(pgrep compton)
或通過systemd
創建服務(自動啟動并限制資源)。四、自動啟動Compton
為了讓Compton隨系統啟動自動運行,可通過以下兩種方式實現:
編輯~/.xprofile
或~/.xinitrc
(取決于登錄方式),添加以下內容:
compton -b --config ~/.config/compton.conf
其中-b
表示后臺運行,--config
指定配置文件路徑。
創建/etc/systemd/system/compton.service
文件,內容如下:
[Unit]
Description=Compton Window Composer
After=xorg.service
[Service]
ExecStart=/usr/bin/compton --config /etc/compton.conf
RestartOnFailure=yes
[Install]
WantedBy=multi-user.target
保存后執行以下命令啟用并啟動服務:
sudo systemctl daemon-reload
sudo systemctl enable compton
sudo systemctl start compton
五、注意事項
killall compton && compton -b --config ~/.config/compton.conf
)。backend
(如從glx
改為wayland
)、禁用特效(如shadow = false
)或更新顯卡驅動。