0

I'm failing to add a custom icon to a custom MIME type file. I don't know what I'm doing wrong, I've followed several tutorials in here and on other websites.

First I created a xml file called org.xml in /usr/share/mime/packages. My file looks like this :

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
    <mime-type type="text/org">
        <comment>Emacs Org-mode File</comment>
        <comment xml:lang="fr">Fichier Emacs Org-mode</comment>
        <glob pattern="*.org"/>
        <icon name="org-icon"/>
        <alias type="text/org"/>
    </mime-type>
</mime-info>

Then I updated the MIME database with the command :

sudo update-mime-database /usr/share/mime

The MIME type association is working and my Org files are detected as text/org but they still have a default file icon.

So I created a 512×512 custom icon and named it org-icon.png.

sudo xdg-icon-resource install --context mimetypes --size 512 --mode system org-icon.png org-icon

This succesfully copy the icon to /usr/share/icons/hicolor/512x512/mimetypes although the icon file seems corrupted and I can't open it using an image viewer. I get the error message : Failed to open input stream for file.

After that I tried to execute :

sudo gtk-update-icon-cache --ignore-theme-index /usr/share/icons/

But nothing changed it doesn't work. My org files still have the default file icon.

What am I doing wrong ? Can't figure it out.

1 Answer 1

0

I found another way to accomplish what I wanted. So I won't accept this answer since it didn't solve my original issue but I'll wait for another answer.


First of all I deleted all changes that I made in /usr/share/mime and /usr/share/icons/ and decided to do it user-wide instead of system-wide.

So I copied my org.xml file into : ~/.local/share/mime/packages then installed my icon using :

xdg-icon-resource install --context mimetypes --size 512 --mode user --theme Adwaita org-icon.png org-icon

I used the --theme option to install the icon in the correct theme folder, the one that I'm currently using (in my case Adwaita) otherwise it won't work. Besides my icon wasn't corrupted anymore and I could open it in an image viewer.

And finally I update the icons cache :

gtk-update-icon-cache --ignore-theme-index ~/.local/share/icons/

This way it worked and I could see my custom icon for my custom MIME type.

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.