1

I tried to create a custom mimetype (text/graphml+xml) by creating the file ~/.local/share/mime/packages/graphml+xml-mime.xml with this content:

<?xml version="1.0" encoding="UTF-8"?>
 <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
   <mime-type type="text/x-graphml+xml">
   <comment>GraphML file</comment>
   <acronym>GraphML</acronym>
   <expanded-acronym>Graph Modelling Language</expanded-acronym>
   <sub-class-of type="text/xml"/>
   <glob pattern="*.graphml"/>
  </mime-type>
 </mime-info>

And installed an appropriate icon with:

xdg-icon-resource-resourse install --context mimetype --novendor --size ${size} --mode user text-x-graphml+xml.png

Then updated the database with

update-mime-database ~/.local/share/mime

But the icon for a my.graphml file is not displayed in nautilus (it's a debian minimal gnome system).

The icons in ~/.local/share/icon/hicolor/${size}x${size}/mimetype/text-x-graphml+xml.png does exist.

gio info my.graphml says:

...
standard::icon: text-x-graphml+xml, text-x-generic, text-x-graphml+xml-symbolic, text-x-generic-symbolic
standard::content-type: text/x-graphml+xml
standard::fast-content-type: text/x-graphml+xml
...

I can double click it and the file is opened with yed (as I want - did create the ~/.local/share/applicatons/yed.desktop file)

But no icon! :-(

0

The fix

Use this XML file instead:

<?xml version="1.0" encoding="UTF-8"?>
 <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
   <mime-type type="application/x-graphml+xml">
   <comment>GraphML file</comment>
   <acronym>GraphML</acronym>
   <expanded-acronym>Graph Modelling Language</expanded-acronym>
   <glob pattern="*.graphml"/>
   <icon name="x-graphml+xml"/>
  </mime-type>
 </mime-info>

and make sure you run xdg-icon-resource with

--context mimetypes

not

--context mimetype

otherwise they'll go in the wrong folder.

For example, if the icon is 48x48, the installation commands will look like this:

xdg-mime install --mode user graphml+xml-mime.xml
xdg-icon-resource install --context mimetypes --size 48 text-x-graphml+xml.png x-graphml+xml
update-mime-database ~/.local/share/mime
update-icon-caches ~/.local/share/icons

Attempt at an explanation

This is a strange one. It appears the difficulty is that when the mimetype is

text/x-graphml+xml

instead of

application/x-graphml+xml

it defaults to the generic text icon. This seems to depend on the file manager and desktop, though.

Is this a bug? You decide!

| improve this answer | |
  • 1.st of all, thanks. Now... It doesn't make much sense to me... what I'd like to register is a "type of file" based on text. Should I install both .xml (the one with <mime-type type="text/x-graphml+xml"> and the one with <mime-type type="application/x-graphml+xml"> )? Or will they conflict with one another? – Ninguém Jun 17 at 13:34
  • 1
    Ideally only one mimetype will be installed, although I don't think they will conflict because whichever is the most recently installed will take priority. – Nathaniel M. Beaver Jun 17 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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