qjda2q
Last Updated: May 03, 2017
·
6.087K
· mhdaljuboori

Create new Mime type and assign an icon to it in Ubuntu

If you want to create new extension like *.todo, assign an icon to it, and open it with your favorite text editor, this is the right place to do so.

Add new Mime Type

You can simple add a new Mime type by going to /usr/share/mime/packages/ and create new XML by coping any file and change it or simply change its content to

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="application/todo">
    <comment>Todos Text file</comment>
    <glob pattern="*.TODO"/>
    <glob pattern="*.todo"/>
  </mime-type>
</mime-info>

As you see we added new Mime type application/todo with two extensions *.TODO and *.todo.

Save the file go back to you Terminal and execute the following command to update mime database

$ sudo update-mime-database /usr/share/mime

Now create any file with extension .todo or .TODO go to its properties, you'll find under the type field Todos Text file (application/todo)

Assign icon to the new extension

First step is renaming the icon to application-todo and it must be in svg extension.

If you're using gnome you have move the icon to /usr/share/icons/gnome/scalable then update the cache with

$ sudo gtk-update-icon-cache /usr/share/icons/gnome -f

If you're using unity move it to /usr/share/icons/Humanity/mimes/ then update the cache

$ sudo gtk-update-icon-cache /usr/share/icons/Humanity -f

Give your nautilus a refresh and you'll have a new Mime type with icon