13

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?

0

3 Answers 3

19

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.

0
10

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.

7

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

2
  • 2
    Please, be a little bit more verbose in your answers.
    – enzotib
    Apr 29, 2011 at 7:30
  • This is already mentioned in the accepted answer. Aug 14, 2019 at 2:38

Not the answer you're looking for? Browse other questions tagged .