一、安裝Compton
Compton是一款輕量級窗口合成器,需先通過包管理器安裝。根據發行版選擇對應命令:
sudo apt-get install compton
sudo dnf install compton
sudo pacman -S compton
二、配置Compton以提升顯示效果
Compton的配置文件通常位于~/.config/compton.conf
(若不存在則手動創建)。以下是關鍵配置選項及說明:
bg_blur true
,使窗口后方區域呈現模糊效果,增強層次感。shadow true
,為窗口邊緣添加陰影,提升立體感和視覺深度。screen_edge_blur true
,讓屏幕邊緣區域產生模糊效果,模擬“無限桌面”的視覺感受。opacity
參數設置全局透明度(如opacity 0.8
表示80%不透明度);或使用opacity-rule
針對特定應用調整(例如opacity-rule ["90:class_g 'Firefox'", "100:class_g 'Xephyr'"]
,Firefox窗口透明度為90%,Xephyr窗口保持不透明)。vsync true
,同步畫面刷新率與顯示器刷新率,減少畫面撕裂現象。ignore_glx_glitz true
,禁用OpenGL加速。三、性能優化技巧
為避免Compton占用過多系統資源(尤其是低配置設備),可通過以下方式優化:
backend
設置為glx
(適用于大多數現代顯卡)或wayland
(若系統支持),替代默認的xrender
,顯著提升渲染性能。shadow
設為false
、bg_blur
設為false
,減少GPU負載。vsync
——若開啟后出現卡頓,可嘗試設為false
。backend glx
可充分利用GPU資源,提升Compton運行效率。cpulimit
工具限制Compton的CPU占用率(例如cpulimit -l 50 -p $(pgrep compton)
,將CPU使用率限制在50%),避免影響系統整體性能。四、啟動與自動運行
重啟Compton應用配置:修改配置文件后,需重啟Compton使更改生效??墒褂靡韵旅睿?/p>
killall compton && compton --config ~/.config/compton.conf &
或通過systemctl
(若使用systemd服務):
sudo systemctl restart compton
設置開機自動啟動:
/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
注意事項