6

I wrote the following .desktop file for my application named Qtag:

[Desktop entry]
Name=Qtag
Comment=Audio tag editor
Exec=qtag
Icon=/usr/share/pixmaps/Qtag.png
Terminal=false
Categories=Multimedia;
Version=1.0
Type=Application

I copied it to /usr/share/applications, but I still cannot find my app in the menu (I use KDE Plasma 5 application launcher). When I try to open the file in Dolphin (the KDE file manager), it says that there is no Type=... entry in the file. I use KDE Plasma 5. The executable and the icon are in the right places (qtag is in /usr/local/bin).

Jonas Stein
  • 4,078
  • 4
  • 36
  • 55

2 Answers2

6

The first line needs to be [Desktop Entry], with a capital E. Otherwise the file isn't recognized as a desktop entry. Dolphin is looking for the Type= line in the [Desktop Entry] section — this could use a more explicit error message!

You shouldn't put files under /usr (except under /usr/local), that's for your distribution. For your own desktop entry files, use ~/.local/share/applications.


If you put .desktop files in random places, they need to be executable — that's a security measure, to avoid accidentally running arbitrary code from files downloaded from the Internet. That doesn't apply if you put the file in a directory that's dedicated to destkop entry files such as /usr/share/applications or ~/.local/share/applications. You can add #!/usr/bin/xdg-open at the beginning to make the file a valid, executable script which will launch the application when executed.

  • Thank you for the answer. But there is no /usr/share/local/applications directory in my system. Should I create it, then? – amethystAnt May 10 '15 at 19:11
  • @amethystAnt I never mentioned a directory /usr/share/local/applications. That's .local/share/applications (note the initial dot) from your home directory. – Gilles 'SO- stop being evil' May 10 '15 at 19:26
  • Adding on here that the .desktop file actually has to be in .local/share/applications or /usr/share/applications, symlinks will not work. (Even symlinks with an executable bit set.) – Eric Canton Apr 12 '21 at 13:58
2

You can use the validation tool desktop-file-validate. It can find your typo and checks for more common mistakes.

$ desktop-file-validate qtag.desktop 
test.desktop: error: first group is not "Desktop Entry"
test.desktop: error: file contains group "Desktop entry", but groups extending the format should start with "X-"

(see also: How to validate/verify .desktop files?)

Jonas Stein
  • 4,078
  • 4
  • 36
  • 55