.desktop file. “There was an error lunching the application”
参考别人的旧文件写的 my-app.desktop
[Desktop Entry]
Encoding=UTF-8
Name=Pycharm
GenericName=Pycharm IDEA
Comment=The Python IDE for Professional Developers
Exec="/home/zhang/Documents/Pycharm/pycharm-community-2017.1.3/bin/pycharm.sh" %f
Icon=/home/zhang/Documents/Pycharm/pycharm-community-2017.1.3/bin/pycharm.png
Terminal=false
Type=Application
Categories=Application;Programme;
双击的时候一直提示上面错误,在ubuntu论坛上找到解决办法:
(https://askubuntu.com/questions/496367/desktop-file-running-sh-script-there-was-an-error-launching-the-application/836842#836842)
desktop-file-validate your-file-here.desktop
“ This was the hidden command I was trying to find since hours. This, Saved my day :-)
This command will show you warning and errors wherever you have gone wrong.Credits : ubuntuforums ”
执行此命令,终端提示:
$ desktop-file-validate Pycharm.desktopPycharm.desktop: warning: key "Encoding" in group "Desktop Entry" is deprecated
Pycharm.desktop: warning: value "Application;Programme;" for key "Categories" in group "Desktop Entry" contains a deprecated value "Application"
Pycharm.desktop: error: value "Application;Programme;" for key "Categories" in group "Desktop Entry" contains an unregistered value "Programme"; values extending the format should start with "X-"
Pycharm.desktop: hint: value "Application;Programme;" for key "Categories" in group "Desktop Entry" does not contain a registered main category; application might only show up in a "catch-all" section of the application menu
根据提示,修改.desktop文件(去掉.desktop文件的Categories的value“Programme”, "Application"改成“X-Application”,Ok)
成功的.desktop文件如下:
[Desktop Entry]
Encoding=UTF-8
Name=Pycharm
GenericName=Pycharm IDEA
Comment=The Python IDE for Professional Developers
Exec="/home/zhang/Documents/Pycharm/pycharm-community-2017.1.3/bin/pycharm.sh" %f
Icon=/home/zhang/Documents/Pycharm/pycharm-community-2017.1.3/bin/pycharm.png
Terminal=false
Type=Application
Categories=X-Application
快捷方式图标的存放位置: /usr/share/applications 。将.desktop 文件移到该目录下。