I am trying to create file associations so I can double click a file and it will open with my program - and will associate an icon with that file type.

I created the file myapp-xxx.xml:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="application/myapp-xxx">
        <comment>My app dummy mime</comment>
        <sub-class-of type="application/octet-stream"/>
        <glob pattern="*.xxx"/>
        <generic-icon name="MyApp"/>

I placed MyApp.png in /usr/share/icons/

I placed myapp-xxx.xml in /usr/share/mime/application/

I ran

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

and my xml promptly disappeared.

I read that it can be because i am missing description... but looking at all the examples, and the existing mimes, I don't see what I am missing.


Note: I have a .desktop file too... but since the mime database removes the mime, I don't think having the reference in the .desktop file will help.

  • Welcome to askubuntu! .xxx is not a valid mime type you will likely have better luck using a valid type. A rather exhaustive list can be found here: sitepoint.com/web-foundations/mime-types-complete-list
    – Elder Geek
    Oct 30 '14 at 19:46
  • You may find this Q&A on superuser.com to be helpful: superuser.com/questions/649928/…
    – Elder Geek
    Oct 30 '14 at 19:49
  • I made xxx up - trying to make a custom mime type - using the file extension of the files saved . If I use an existing mime type, I may as well just use application/octet-stream right ? Just read the link above - so i must place my mime description in the packages not application - and have to name it after my application, without the little extra I added ? what if an application installs multiple mime types ?
    – Thalia
    Oct 30 '14 at 19:54
  • Hopefully the Q&A on superuser.com will more helpful in allowing you to achieve your intendeed result.
    – Elder Geek
    Oct 30 '14 at 20:01
  • I moved the xml file in packages and it didn't get deleted anymore. Running mimetype -a myfile.xxx showed both mime types.
    – Thalia
    Oct 30 '14 at 20:02

I placed the file myapp-xxx.xml in /usr/share/mime/packages/ (instead of /usr/share/mime/application/)

Running sudo update-mime-database /usr/share/mime did not remove my xml file...

Running mimetype -a Desktop/abcd.xxx showed

Desktop/abcd.xxx: application/myapp-xxx
Desktop/abcd.xxx: application/octet-stream

Thank you Elder Geek for the resource.

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.