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 and the application does show in the applications pannel with the appropriate icon).

But no icon! :-(

EDIT:

It's a debian testing system, installed with debootstrap and grown from there (trying to keep it minimal). I'm afraid this might also mean some packages might be missing...

1 Answers1

1

Nathaniel M. Beaver is right - this is the same question he already answered in Assign an icon to a custom mimetype - Unix & Linux

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.

Kulfy
  • 18,154