Compton是一款輕量級窗口合成器,專為Linux桌面設計,通過窗口合成技術提升視覺效果(如陰影、透明度、模糊),同時保持低資源占用,完美兼容Openbox、i3等窗口管理器。對于Ubuntu用戶,Compton是優化桌面流暢度的理想工具。
在Ubuntu系統中,通過終端執行以下命令即可安裝Compton:
sudo apt-get install compton
安裝完成后,Compton會自動集成到系統中,但默認未啟用。
Compton的配置文件位于~/.config/compton.conf(若不存在則手動創建)。以下是關鍵參數設置,兼顧視覺效果與性能:
shadow = false;
false可顯著提升性能:opacity = 1.0; # 完全不透明
glx(OpenGL加速)或wayland(現代協議),避免xrender(性能較差):backend = "glx";
true):vsync = true;
ignore_root = true;
bg_blur,但會增加GPU負載,建議在高性能設備上使用:bg_blur = true;
shadow = true;
shadow-exclude = ["class_g 'gnome-terminal'", "class_g 'nautilus'"];
shadow-opacity = 0.3;
shadow-radius = 5;
fps-limit = 60;
glx-no-stencil = true; # 禁用模板緩沖區,提升性能
glx-use-copysubbuffermesa = true; # 優化緩沖區操作
cpulimit工具限制其資源占用(例如限制為50%):cpulimit -l 50 -p $(pgrep compton)
修改配置文件后,通過以下命令重啟Compton使更改生效:
killall compton && compton -c ~/.config/compton.conf -f
(-c指定配置文件路徑,-f表示前臺運行,方便查看日志)。
創建Systemd服務文件/etc/systemd/system/compton.service,內容如下:
[Unit]
Description=Compton Window Composer
After=graphical.target # 確保在圖形界面啟動后運行
[Service]
ExecStart=/usr/bin/compton --config /home/你的用戶名/.config/compton.conf
Restart=on-failure # 失敗時自動重啟
User=你的用戶名
[Install]
WantedBy=multi-user.target
保存后執行以下命令啟用并啟動服務:
sudo systemctl daemon-reload
sudo systemctl enable compton
sudo systemctl start compton
=兩側是否有空格),或通過compton --config ~/.config/compton.conf --verbose查看詳細日志。screen_edge_blur),或升級顯卡驅動。vsync(vsync = false),或調整fps-limit值。通過以上步驟,你可根據Ubuntu設備的硬件配置(如CPU、GPU性能)和個人偏好,調整Compton參數,打造流暢且美觀的桌面體驗。記得根據實際效果靈活調整,優先保證性能再追求視覺效果。