Ubuntu – Associating files with same MIME but different file extensions to differentt applications

file associationfile formatgnomemime-type

How can I associate files with same MIME but different extensions to different applications.
For example both .maff & .zip files have application/zip MIME ; But I need to open .maff by Firefox and .zip by ArchiveManager
Setting this via Open with dialog associates application to MIME that causes both files open with same application.
How can I configure this in Gnome?
I'm using Ubuntu Lucid Lynx.

Thanks

Best Answer

I strove to make Firefoxmaff association only for one user (me). So I didn't touch files under /etc.

I did the following:

  1. Restore correct association between ZIP-files and archive manager (I did it within default file manager Nemo).

  2. Create definition of MIME type. In my case I created firefox-maff-my.xml file in ~/.local/share/mime/packages directory with the content provided below:

    <?xml version="1.0" encoding="UTF-8"?>
    <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
      <mime-type type="application/maff">
             <comment>Mozilla Archive Format</comment>
             <glob pattern="*.maff"/>
      </mime-type>
    </mime-info>
    
  3. Update MIME database

    update-mime-database ~/.local/share/mime/
    
  4. Edit ~/.local/share/applications/mimeapps.list. Add

    application/maff=firefox.desktop
    

    line right under [Default Applications].

  5. Log out, then log in.

In case of doubts you can make backup of each involved file before editing it. If something will go wrong you can revert everything you did (just restore original files, remove firefox-maff-my.xml and run update-mime-database ~/.local/share/mime/ again).


I've faced similar issue in Linux Mint 17.1 Cinnamon. Perhaps this also will work for GNOME (because both follow freedesktop.org).