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
    To start with, which version of Linux have you installed  (Ubuntu server, Ubuntu desktop, Kubuntu, Lubuntu, Xubuntu, Ubuntu MATE, et al.) , and which release number? Different releases have different tools for us to recommend. Please click [edit] and add that vital information to your question so all the facts we need are in the question. Please don't use Add Comment, since that's our channel to you. All facts about your system should go in the Question with [edit] – K7AAY May 13 '20 at 16:04
  • Related / duplicate: https://unix.stackexchange.com/questions/585997/assign-an-icon-to-a-custom-mimetype – Nathaniel M. Beaver Jun 17 '20 at 19:42
  • Please refer https://askubuntu.com/help/on-topic, Ubuntu and official flavors of Ubuntu (https://ubuntu.com/download/flavours) are on-topic on this site. The on-topic link provides alternate SE sites for non-Ubuntu OSes. – guiverc Jul 06 '22 at 08:06

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,163