Search code examples
user-interfacegnomekde-plasmafreedesktop.orgdesktop-integration

Where to install icon for a user-specific application while adhering to FreeDesktop standards?


I have a GUI application that I want to install per-user in a FreeDesktop-compliant manner. Reading the relevant specifications, it seem that a '.desktop' file should be placed in ~/.local/share/applications, and that it should contain an Icon key set to the name of the icon without extensions.

The issue I'm facing is that I can't find per-user location where I should store the icon. The Icon Theme specification state that application icons should at least be stored in $prefix/share/icons/hicolor/48x48/apps, but it never defines what values $prefix takes. It mentions $HOME/.icons but depricates it as legacy. All other paths I found were system-wide.

Gnome's Integration Guide specifies that icons should be stored in /usr/share/icons/hicolor/48x48/apps/ but makes no mention of per-user installation despite alluding to per-user installations elsewhere in the guide.

Given that what I managed to find does not provide me with the information I want, I ask this:

Where should a place my application's icon so that xdg desktops can find them?

Kindly note that I am aware of kde4-config --path icon and friends. I want to avoid handling icons for every desktop I want to support if possible.


Solution

  • Rereading the XDG Icon Specification, I noticed the specification references the XDG Base Directory Specification by including $XDG_DATA_DIRS. This inclusion implies that that the Base Directory Specification is also in effect, which in turn mandates that

    Lookups of the data file should search for ./subdir/filename relative to all base directories specified by $XDG_DATA_HOME and $XDG_DATA_DIRS . If an environment variable is either not set or empty, its default value as defined by this specification should be used instead. (src)

    So, assuming my understanding is correct and XDG desktops adhere to specs, the user-specific icon location for your application is $XDG_DATA_HOME/icons/hicolor/48x48/apps/$YOURAPP.(png|xpm) and $XDG_DATA_HOME/icons/hicolor/scalable/apps/$YOURAPP.svg. File extensions are case-sensitive and only these three extensions are allowed. Also note that SVG support is optional.

    If $XDG_DATA_HOME is not set, you should default to $HOME/.local/share as per the Base Directory Specification.