I am working with MATLAB most of my time and I'd be happy to visually differ code files (.m), data files (.mat), figures (.fig). Quite an obvious thing that turns to be pretty peculiar.

Here I am now:

  • added new mime entry application/matlab m mat fig in /etc/mime.types
  • icons matlab-m.png, matlab-fig.png, matlab-mat.png are put into /usr/share/icons/gnome/8x8...512x512/mimetypes (each folder correct size) and .svg with same names to /usr/share/icons/gnome/scalable/mimetypes
  • put XML named matlab.xml in /usr/share/mime/packages

Here is my .xml:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="application/matlab-m">
    <comment>Matlab source code</comment>
    <glob pattern="*.m"/>
    <icon name="matlab-m"/>
  <mime-type type="application/matlab-fig">
    <comment>Matlab figure</comment>
    <glob pattern="*.fig"/>
    <icon name="matlab-fig"/>
  <mime-type type="application/matlab-mat">
    <comment>matlab data</comment>
    <glob pattern="*.mat"/>
    <icon name="matlab-mat"/>

These actions didn't make system to read icons for .m and .fig files, but suddenly icon for .mat files is detected. Please show me where am I wrong.

1 Answer 1


Ok, it appeared, that assigning icons for filetypes in Ubunty is a trickier task than one could think. Anyway, I've found a pretty clear explanation in case someone with the same desire finds this page. In short:

A. Create a definition for an unknown filetype:

  1. If your file has uncommon type, so that Ubuntu has problems with detecting / defining it correctly, you need to do it yourself. Such identification is called «MIME type». The MIME type is specified as an .xml document. Here's my example (data file used by Matlab):

  2. Put .xml file with MIME type to /usr/share/mime/packages — all users ~/.local/share/mime/packages — one user

  3. Update database of MIME types: sudo update-mime-database /usr/share/mime In case of success, a new folder matlab-types was created at /usr/share/mime, containing an auto-generated file matlabdata.xml. Note how it was done according to the type="matlab-types/matlabdata" from our custom MIME type definition. In case I will need to create other Matlab-related MIME types, I will add another <mime-type> ... </mime-type> section in my .xml and the related files will be stored in the same /usr/share/mime/matlab-types directory.

B. Set an icon for a (custom) MIME type:

  1. Rename your icon according to type="matlab-types/matlabdata" from .xml file, but replace '/' with '-': "custom-types-matlabdata.svg"

  2. Put it to the folder, where icons related to your desktop theme are stored:

    sudo cp icon.svg /usr/share/icons/{THEME}/scalable/mimetypes/custom-types-matlabdata.svg

Note, that you can put vector images to …/scalable/… folder. If you have raster .png icons you have to create a set of copies with different scale and put them to their respective folders:

/usr/share/icons/{THEME}/(8x8, 16x16, 22x22…)/mimetypes/…
  1. Update icon cashe (relogin/restart not required):

    sudo update-icon-caches /usr/share/icons/*

  2. DONE!

PS. A little helping code to manipulate icons: put in .sh file and run with sudo


pasteName="(CATEGORY DIR)-(MIME TYPE).svg"
iconsDir="/usr/share/icons" # "~/.icons"

cp "$copyFrom/$copyName" "$copyTo/$pasteName" && \
echo "FROM:\n\t$copyName\n\t$storagedir\n\nTO:\n\t$pasteName\n\t$pasteTo\n\n"

update-mime-database /usr/share/mime
gtk-update-icon-cache $iconsDir/$themeName/ -f

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.