- 1 Basics
- 2 Application entry
- 3 Icons
- 4 Tools
- 5 Tips and tricks
- 6 See also
Each desktop entry must have a
Type and a
Name key and can optionally define its appearance in the application menu.
The three available types are:
- Defines how to launch an application and what MIME types it supports (used by XDG MIME Applications). With XDG Autostart Application entries can be started automatically by placing them in specific directories. Application entries use the
.desktopfile extension. See #Application entry.
- Defines a shortcut to a
URL. Link entries use the
- Defines the appearance of a submenu in the application menu. Directory entries use the
The following sections will roughly explain how these are created and validated.
Desktop entries for applications, or
.desktop files, are generally a combination of meta information resources and a shortcut of an application. These files usually reside in
/usr/local/share/applications/ for applications installed system-wide, or
~/.local/share/applications/ for user-specific applications. User entries take precedence over system entries.
Following is an example of its structure with additional comments. The example is only meant to give a quick impression, and does not show how to utilize all possible entry keys. The complete list of keys can be found in the freedesktop specification.
[Desktop Entry] # The type as listed above Type=Application # The version of the desktop entry specification to which this file complies Version=1.0 # The name of the application Name=jMemorize # A comment which can/will be used as a tooltip Comment=Flash card based learning tool # The path to the folder in which the executable is run Path=/opt/jmemorise # The executable of the application, possibly with arguments. Exec=jmemorize # The name of the icon that will be used to display this entry Icon=jmemorize # Describes whether this application needs to be run in a terminal or not Terminal=false # Describes the categories in which this entry should be shown Categories=Education;Languages;Java;
All recognized entries can be found on the freedesktop site.
For example, the
Type key defines three types of desktop entries: Application (type 1), Link (type 2) and Directory (type 3).
Versionkey does not stand for the version of the application, but for the version of the desktop entry specification to which this file complies.
Commentoften contain redundant values in the form of combinations of them, like:
Name=Pidgin Internet Messenger GenericName=Internet Messenger
Name=NoteCase notes manager Comment=Notes Manager
This should be avoided, as it will only be confusing to users. The
Name key should only contain the name, or maybe an abbreviation/acronym if available.
GenericNameshould state what you would generally call an application that does what this specific application offers (i.e. Firefox is a "Web Browser").
Commentis intended to contain any usefull additional information.
As some keys have become deprecated over time, you may want to validate your desktop entries usingwhich is part of the package. To validate, run:
$ desktop-file-validate <your desktop file>
This will give you very verbose and useful warnings and error messages.
Update database of desktop entries
To make desktop entries defined in
~/.local/share/applications work, run the following command:
$ update-desktop-database ~/.local/share/applications
See also the Icon Theme Specification.
Common image formats
Here is a short overview of image formats commonly used for icons.
|Extension||Full Name and/or Description||Graphics Type||Container Format||Supported|
|.png||Portable Network Graphics||Raster||No||Yes|
|.svg(z)||Scalable Vector Graphics||Vector||No||Yes (optional)|
|.xpm||X PixMap||Raster||No||Yes (deprecated)|
|.gif||Graphics Interchange Format||Raster||No||No|
|.ico||MS Windows Icon Format||Raster||Yes||No|
|.icns||Apple Icon Image||Raster||Yes||No|
If you stumble across an icon which is in a format that is not supported by the freedesktop.org standard (like
ico), you can use the convert tool (which is part of the package) to convert it to a supported/recommended format, e.g.:
$ convert <icon name>.gif <icon name>.png
If you convert from a container format like
ico, you will get all images that were encapsulated in the
ico file in the form
<icon name>-<number>.png. If you want to know the size of the image, or the number of images in a container file like
ico you can use the identify tool (also part of the package):
$ identify /usr/share/vlc/vlc48x48.ico
/usr/share/vlc/vlc48x48.ico ICO 32x32 32x32+0+0 8-bit DirectClass 84.3kb /usr/share/vlc/vlc48x48.ico ICO 16x16 16x16+0+0 8-bit DirectClass 84.3kb /usr/share/vlc/vlc48x48.ico ICO 128x128 128x128+0+0 8-bit DirectClass 84.3kb /usr/share/vlc/vlc48x48.ico ICO 48x48 48x48+0+0 8-bit DirectClass 84.3kb /usr/share/vlc/vlc48x48.ico ICO 32x32 32x32+0+0 8-bit DirectClass 84.3kb /usr/share/vlc/vlc48x48.ico ICO 16x16 16x16+0+0 8-bit DirectClass 84.3kb
As you can see, the example ico file, although its name might suggest a single image of size 48x48, contains no less than 6 different sizes, of which one is even greater than 48x48, namely 128x128.
Alternatively, you can use icotool (from) to extract png images from ico container:
$ icotool -x <icon name>.ico
For extracting images from .icns container, you can use icns2png (provided by):
$ icns2png -x <icon name>.icns
Although packages that already ship with a .desktop file most certainly contain an icon or a set of icons, there is sometimes the case when a developer has not created a .desktop file, but may ship icons, nonetheless. So a good start is to look for icons in the source package. You can i.e. first filter for the extension with find and then use grep to filter further for certain buzzwords like the package name, "icon", "logo", etc, if there are quite a lot of images in the source package.
$ find /path/to/source/package -regex ".*\.\(svg\|png\|xpm\|gif\|ico\)$"
If the developers of an application do not include icons in their source packages, the next step would be to search on their web sites. Some projects, like i.e. tvbrowser have an artwork/logo page where additional icons may be found. If a project is multi-platform, there may be the case that even if the linux/unix package does not come with an icon, the Windows package might provide one. If the project uses a Version control system like CVS/SVN/etc. and you have some experience with it, you also might consider browsing it for icons. If everything fails, the project might simply have no icon/logo yet.
The freedesktop.org standard specifies in which order and directories programs should look for icons:
$HOME/.icons(for backwards compatibility)
started as an Arch Linux-specific tool for generating .desktop files by fetching the needed information directly from PKGBUILD files. Now it is a general tool that takes command-line arguments.
Icons can be automatically downloaded from openiconlibrary, if available. (The source for icons is configurable).
How to use
- Start the
gendesk --pkgname "$pkgname" --pkgdesc "$pkgdesc"
- Alternatively, if an icon is already provided ($pkgname.png, for instance). The
-nflag is for not downloading an icon or using the default icon. Example:
gendesk -n --pkgname "$pkgname" --pkgdesc "$pkgdesc"
$srcdir/$pkgname.desktopwill be created and can be installed in the
install -Dm644 "$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"
- The icon can be installed with:
install -Dm644 "$pkgname.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"
--name='Program Name'for choosing a name for the menu entry.
--exec='/opt/some_app/elf --some-arg --other-arg'for setting the exec field.
- See the gendesk project for more information.
AUR can list available .desktop files or search their contents.
$ lsdesktopf $ lsdesktopf --list $ lsdesktopf --list gtk zh_TW,zh_CN,en_GB
It can also perform MIME-type-related searches. See XDG MIME Applications#lsdesktopf.
Exec values pointing to non-existent paths. Without any arguments it uses preset directories in the
DskPath array. It shows only broken .desktop with full path and filename that is missing.
$ fbrokendesktop $ fbrokendesktop /usr $ fbrokendesktop /usr/share/apps/kdm/sessions/icewm.desktop
Tips and tricks
Run a desktop file from a terminal
Hide desktop entries
Firstly, copy the desktop entry file in question to
~/.local/share/applications to avoid your changes being overwritten.
Then, to hide the entry in all environments, open the desktop entry file in a text editor and add the following line:
To hide the entry in a specific desktop, add the following line to the desktop entry file:
where desktop-name can be option such as GNOME, Xfce, KDE etc. A desktop entry can be hidden in more than desktop at once - simply separate the desktop names with a semi-colon.
Modify environment variables
To set environment variables, copy the .desktop file from
~/.local/share/applications/) and edit the
Exec= command line by prepending env. For example:
Exec=env LANG=he_IL.UTF-8 abiword %U