Linux – MIME type for custom file types

MIME type for custom file types… here is a solution to the problem.

MIME type for custom file types

I’m trying to register a custom file type as a MIME type in Linux. My custom file type (with a custom extension) is actually a zip archive containing various xml and other files.

The problem I’m having is that my operating system (kubuntu) doesn’t recognize the file as my custom mime type and instead insists it’s a zip file.

I’m not sure where to start trying to solve my problem. I used the following mime information file (tugraz-caleydo.sharedmimeinfo):

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/x-cal">  
<comment>Caleydo Project</comment>
<glob pattern="*.cal"/>
</mime-type>
</mime-info>

My desktop entry (caleydo.desktop, properly registered in /usr/share/applications):

[Desktop Entry]
Version=2.01
Encoding=UTF-8
Name=Caleydo
GenericName=Data Visualization 
Comment=Visualization for Molecular Biology
Exec=/usr/bin/caleydo
Icon=/usr/share/pixmaps/caleydo_256.png
StartupNotify=true
Type=Application
Categories=Science;
MimeType=application/x-cal;

These are the commands I tried to use:

sudo xdg-mime install --mode system tugraz-caleydo.sharedmimeinfo
sudo xdg-mime default caleydo.desktop application/x-cal
sudo update-mime-database /usr/share/mime

However, this still gives me :

$ xdg-mime query filetype export_2012.cal 
application/zip

Solution

Finally found the problem :

The MIME

information file must have the exact same name as the MIME type. Rename it to x-cal.xml and you’re good to go.

Related Problems and Solutions