6

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
48x48 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?

4
  • 1
    I noticed that placing these icons in local profile isn't enough. But if you place them in the same folder, where your DE stores its icons, they will work fine. Dunno where Linux Mint stores its icons, but you can discover it. Check this post: askubuntu.com/a/752316/123714
    – whtyger
    Apr 5, 2016 at 13:39
  • @whtyger - Thanks, I'll try it. BTW, thank you for being an "excavator" (as your bronze badge tells us). Apr 5, 2016 at 15:46
  • @whtyger - Thank you, it works now! I was unaware of gtk-update-icon-cache and /etc/mime.types. Apr 7, 2016 at 5:14
  • You are welcome. I spent much time to overcome this minor but annoying issue. Glad to hear that my findings can save some time of others'.
    – whtyger
    Apr 7, 2016 at 8:08

1 Answer 1

4

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".
2
  • 2
    The first step is optional. It is needed only for several applications, Apache for example. File manager displays icons of custom mimetype without this addition. Also there's no need to change /etc/mime.types, you can create ~/.mime.types and add your custom types there. In the 2nd step gnome-mime-text-x-session.png symlink can also be omitted. Only mimetype-named icon will suffice. And the last piece of advice: add the same icons with appropriate sizes to the 32/ 24/ and 16/ folders so your custom mimetype's icons will be properly displayed in the menus and different apps.
    – whtyger
    Apr 7, 2016 at 8:07
  • The third step helped a lot. (i'm using nemo)
    – imkzh
    Nov 29, 2021 at 2:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .