Linux – How to set an icon for custom mimetype in Linux Mint Mate

iconslinux-mintmime-typesxdg

I'm using Linux Mint 17.2 MATE
I have a problem assigning an icon for custom (newly created) file type.

My task:
To set new double-click action and new icon for *.session files.

My sequence of operations:

xdg-mime install --novendor scite_session.xml
xdg-icon-resource install --context mimetypes --size 48 text-x-session.png text-x-session
xdg-desktop-menu install --novendor scite_session.desktop
xdg-mime default scite_session.desktop text/x-session

No errors have been displayed during these steps.
Finally I've rebooted OS.

My files (used in the above steps):

text-x-session.png
48×48 PNG image file

scite_session.xml

<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
   <mime-type type="text/x-session">
      <comment>SciTE session file</comment>
      <sub-class-of type="text/plain"/>
      <glob pattern="*.session"/>
      <icon name="text-x-session"/>
   </mime-type>
</mime-info>

scite_session.desktop

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=SciTE (session)
Comment=Loading SciTE session
GenericName=Text Editor
Type=Application
Exec=SciTE -loadsession:%f
Icon=Sci48M
Terminal=false
Categories=
StartupNotify=true
MimeType=text/x-session;

My results:
Everything seems to be OK except icons.

  • I see proper type "text/x-session" in "properties" page of any *.session file
  • Double-clicking on any *.session file invokes proper action according to "scite_session.desktop"
  • But the icon used by caja for *.session files is still the same instead of my new icon.

My question:
How to set new icon for mimetype in Linux Mint?

I've noticed that xdg-icon-resource created a copy of my .png in ~/.local/share/icons/hicolor/48x48/mimetypes
Probably, I should copy it manually somewhere else?

Best Answer

There were necessary steps I was unaware of.

  1. Add text/x-session session line to /etc/mime.types
  2. Copy icon file to theme folder:

    $ sudo cp my_icon.png /usr/share/icons/Mint-X/mimetypes/48/text-x-session.png
    $ sudo ln -s text-x-session.png /usr/share/icons/Mint-X/mimetypes/48/gnome-mime-text-x-session.png
    $ sudo gtk-update-icon-cache /usr/share/icons/Mint-X
    
  3. Make icons always visible (prevent replacing icons with microtext):

    • Enter caja menu -> Edit -> Preferences -> Preview
    • Set "Show Text in Icons" to "Never".
Related Question