Desktop launcher documentation? [duplicate]

Possible Duplicate:
What is the syntax for .desktop files?
How do I add a custom launcher?

I prefer to create new desktop launchers (.desktop files) using just a text editor, for example to create an iotop launcher I write:

[Desktop Entry]
Name=iotop
Exec=gksudo "gnome-terminal -x iotop"
Type=Application

But I haven't found any documentation on the format. Can someone give me a link to the format specification?


Solution 1:

The .desktop file specification is here: http://standards.freedesktop.org/desktop-entry-spec/latest/

An example .desktop file would be:

[Desktop Entry]
Version=1.0
Type=Application
Name=Foo Viewer
Comment=The best viewer for Foo objects available!
TryExec=fooview
Exec=fooview %F
Icon=fooview
MimeType=image/x-foo;
NotShowIn=KDE;

A .desktop file can have translations integrated, by specifying the language:

Name=Foo Viewer
Name[en_GB]=Foo Viewer
Name[el_GR]=Φου Βιούερ

If you want to add unity submenus to unity panel icon, then you can create a desktop file. An example from http://maketecheasier.com/8-really-useful-ubuntu-unity-quicklists/2011/05/07

First copy the original .desktop file and open it with your favourite text editor:

cp /usr/share/applications/firefox.desktop ~/.local/share/applications
gedit ~/.local/share/applications/firefox.desktop

Then edit the file:

[Desktop Entry]
Version=1.0
Name=Firefox Web Browser
GenericName=Web Browser
Exec=firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=firefox
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;
StartupWMClass=Firefox
StartupNotify=true
X-Ayatana-Desktop-Shortcuts=NewWindow;Private;Safe;ProfileManager;MakeTechEasier

Name[en_US]=Firefox Web Browser

[NewWindow Shortcut Group]
Name=Open a New Window
Exec=firefox -new-window
TargetEnvironment=Unity

[Private Shortcut Group]
Name=Private Mode
Exec=firefox -private-toggle
TargetEnvironment=Unity

[Safe Shortcut Group]
Name=Safe Mode
Exec=firefox -safe-mode
TargetEnvironment=Unity

[ProfileManager Shortcut Group]
Name=Start Profile Manager
Exec=firefox -ProfileManager
TargetEnvironment=Unity

Now run nautilus ~/.local/share/applications/ and drag-and-drop your newly-created "Firefox" unity desktop file in the unity bar.

Solution 2:

The format of .desktop configuration files is a unified standard and described in the FreeDesktop.org Desktop Entry Specification. The files specify how an application is launched, how it appears in menus, and so forth.

The GNOME Dev Center has a good tutorial on creating these files for your own applications.

Solution 3:

You can find information about .desktop file here: Desktop Entry Specification