1. 程式人生 > >[Ubuntu].desktop檔案錯誤資訊除錯

[Ubuntu].desktop檔案錯誤資訊除錯

[Ubuntu].desktop file. “There was an error lunching the application”

設定Eclipse啟動圖示時,編寫**.desktop** 檔案,在啟動欄找不到圖示,並且在目錄下也無法啟動,顯示資訊:

“There was an error lunching the application”

解決辦法:執行desktop-file-validate對檔案錯誤資訊進行除錯。

cd /usr/share/applications
desktop-file-validate eclipse.desktop

.desktop file set-up

  1. 進入applications目錄
cd /usr/share/applications
  1. 編寫檔案
sudo vim eclipse.desktop

add text :

[Desktop Entry]
Name=Eclipse
Comment=eclipse 
Exec=/usr/local/eclipse/eclipse
Icon=/usr/local/eclipse/icon.xpm
Terminal=false
StartupNotify=true
Type=Application
Categories=Application;Development;
  1. 除錯
    執行出現錯誤資訊:
“There was an error lunching the application”

debug:

/applications$ desktop-file-validate eclipse.desktop
eclipse.desktop: error: line "[Desktop Entry] " ends with a space, but looks like a group. The validation will continue, with the trailing spaces ignored.
eclipse.desktop: warning: value "eclipse "
for key "Comment" in group "Desktop Entry" looks redundant with value "Eclipse " of key "Name" eclipse.desktop: error: value "false " for boolean key "Terminal" in group "Desktop Entry" contains invalid characters, boolean values must be "false" or "true" eclipse.desktop: error: value "true " for boolean key "StartupNotify" in group "Desktop Entry" contains invalid characters, boolean values must be "false" or "true" eclipse.desktop: error: value "Application " for key "Type" in group "Desktop Entry" is not a registered type value ("Application", "Link" and "Directory") eclipse.desktop: warning: value "Application;Development; " for key "Categories" in group "Desktop Entry" contains a deprecated value "Application" eclipse.desktop: error: value "Application;Development; " for key "Categories" in group "Desktop Entry" contains an unregistered value " "; values extending the format should start with "X-"

發現錯誤,所有語句後面都多了空格,導致命令資訊錯誤。把多餘空格資訊刪除,重新執行成功。
4. 測試通過
開啟程式欄,輸入eclipse,成功執行。

總結

  • .desktop檔案不會自動忽略空格,多餘空格導致命令錯誤。
  • .desktop檔案可以用desktop-file-validate除錯