3

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

1 Answer 1

1

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!

2
  • 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
    Commented Jun 17, 2020 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. Commented Jun 17, 2020 at 13:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .