Icon / mime association..

Magnus Bergman magnus.bergman at observer.net
Wed Oct 11 17:00:03 EEST 2006

On Wed, 11 Oct 2006 00:01:44 +0300
Kustaa Nyholm <feedback2 at sparetimelabs.com> wrote:

> Hi List,
> new here, so excuse me if this is wrong place to ask this question.
> I've tried to do my home work, spent some ten hours in the web but I
> still do not know the answer.
> How do I do file/mime/application associations in the freedesktop.org
> style?
> I understand that I create a myapp.xml file in /usr/bin/mime/packages
> and then run update-mime-database.

The file to mimetype association is handled by the package
shared-mime-info [1]. Put a file in DATADIR/mime/ and update the
database to have it registered. Or perhaps send a patch so it can be
included in shared-mime-info.

For application to mime association just put a ';' separated list of
mimetypes in the MimeType [2] entry of the .desktop file for your

> But as far as I understand this only associates, in practical terms,
> my mime type, a description of the type and file extension together,
> no icon.

The icon for a mimetype is expected to be in
DATADIR/icons/THEME/*/mimetypes. In other words, the icon used depends
on the current theme [3]. If you want to install a default icon for your
own mimetype it might be sensible to put it in the hicolor (default)
theme. Note that your application icon also can be themed if you put it
in DATADIR/icons/hicolor/*/apps, which is probably what you want.

> I then  create a myapp.desktop file and run update-desktop-database
> which associates my mime type, executable and icon and a description
> of the application.
> Now the part I don't understand:
> The icon in the .desktop file, is that an icon for the application or
> the document (mime typed) file? Or both?

It is the icon of the application. There is no direct link between
application and mimetypes, these are treated like two independent
things. One application can support any number of mimetypes and one
mimetype can be supported be any number of applications. Many mimetypes
are not handled by any installed application, but the are still
recognized as expected.

> How can I get a separate icon for the application and document? What
> if my application supports several document (mime) types?

That isn't a problem, see above.

> I figured this could be be done with a .desktop file with the
> Type=Mimetype and Patterns=*.ext but these are deprecated?

Yes, those are deprecated. Use MimeType instead. See above.

> I've read the icon naming spec and icon theme spec but I just don't
> get it.

[1] http://freedesktop.org/wiki/Standards_2fshared_2dmime_2dinfo_2dspec


[3] http://freedesktop.org/wiki/Standards_2ficon_2dtheme_2dspec

More information about the xdg mailing list