Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I had a look at the .desktop files on my 12.04 Ubuntu system, and many of them do not have a full path specification for their icon file. It is rather something like:

Icon=anjuta

or

Icon=vlc

or

Icon=application-x-clementine

Is there a common path where icons can be stored so that this can work ? If not, how does this work ? If I try to do the same thing with my own icons I have to specify the full path.

e.g.

Icon=/usr/local/share/my-icon.png

works fine, but

Icon=my-icon.png

will fail.

Any kind of help is welcome!

share|improve this question

3 Answers 3

Yeah the lookup is pretty complicated. Here are the freedesktop icon specifications on directory layouts:

Icons and themes are looked for in a set of directories. By default, apps should look in $HOME/.icons (for backwards compatibility), in $XDG_DATA_DIRS/icons and in /usr/share/pixmaps (in that order). Applications may further add their own icon directories to this list, and users may extend or change the list (in application/desktop specific ways).In each of these directories themes are stored as subdirectories. A theme can be spread across several base directories by having subdirectories of the same name. This way users can extend and override system themes.

In order to have a place for third party applications to install their icons there should always exist a theme called "hicolor" 1. The data for the hicolor theme is available for download at: http://www.freedesktop.org/software/icon-theme/. Implementations are required to look in the "hicolor" theme if an icon was not found in the current theme.

Each theme is stored as subdirectories of the base directories. The internal name of the theme is the name of the subdirectory, although the user-visible name as specified by the theme may be different. Hence, theme names are case sensitive, and are limited to ASCII characters. Theme names may also not contain comma or space.

In at least one of the theme directories there must be a file called index.theme that describes the theme. The first index.theme found while searching the base directories in order is used. This file describes the general attributes of the theme.

In the theme directory are also a set of subdirectories containing image files. Each directory contains icons designed for a certain nominal icon size, as described by the index.theme file. The subdirectories are allowed to be several levels deep, e.g. the subdirectory "48x48/apps" in the theme "hicolor" would end up at $basedir/hicolor/48x48/apps.

The image files must be one of the types: PNG, XPM, or SVG, and the extension must be ".png", ".xpm", or ".svg" (lower case). The support for SVG files is optional. Implementations that do not support SVGs should just ignore any ".svg" files. In addition to this there may be an additional file with extra icon-data for each file. It should have the same basename as the image file, with the extension ".icon". e.g. if the icon file is called "mime_source_c.png" the corresponding file would be named "mime_source_c.icon".

The full specifications are much more exhausti{ve,ng} than this but the crux of it is: there are set directories you can just stuff icons into and the desktop will find them. Which of those best applies to you depends on your problem and your patience :)

share|improve this answer
    
nice info. I thought I new a few things on desktop files, but this is a lot of new information. I will look into this. –  Jacob Vlijm Mar 17 at 20:49
    
Absolutely super answer thanks for this quote. –  Noitidart Aug 28 at 6:05

I have experience with just emblems, not icons, but that should work:

mkdir -p $HOME/.icons/hicolor/48x48/

put the icon in that directory, let's suppose it is myicon.png

cp  myicons.png $HOME/.icons/hicolor/48x48/

Add the description file:

gedit $HOME/.icons/hicolor/48x48/myicon.icon

with content:

[Icon Data]

DisplayName=myicon

and now your Icon=myicon line should work. It works with emblems if you put them in an "emblems" subdirectory:

personalized emblem

Thanks to @Oli now I know why it works :-)

share|improve this answer
    
No way i did not know about emblems, super answer. I was actually making a badged/emblemed png than setting it to that. This is great man thanks. Is it just ubuntu that supports emblem? or all linux builds? –  Noitidart Aug 28 at 6:06
    
@Noitidart: I think it's basically a File Manager thing. They work at least in nautilus and in thunar (so in Ubuntu, Ubuntu Gnome, and XUbuntu; and in other distros using them). Never checked with the K-side. –  Rmano Aug 28 at 6:46

If you put icons in /usr/share/icons/ (for system wide) or in your home ~/.icons, then you can use only the icon file name without the extension in the .desktop file. E.g.

Icon=vlc

If not, then you must to use the absolute path for the icon in the .desktop file. E.g.

Icon=/usr/local/share/my-icon.png
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.