I would like to be able to open them by double clicking in the file manager and also having a nice icon for the files.
To achieve this I needed to create a new mime-type for .ipynb files
Creating a new mime type
There are many ways to create mime-types in Ubuntu, but this is what I did. I used this blog post by termueske as a guide.I created a text file called ipynb.xml on my desktop with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/x-ipynb+json">
<comment>IPython Notebook</comment>
<glob pattern="*.ipynb"/>
</mime-type>
</mime-info>
I then opened a terminal in desktop and typed the following command:
bjorn@bjorn-UL30A:~/Desktop$ xdg-mime install ipynb.xml --novendor
If there is no response, everything is ok. Then I updated the mime database:
bjorn@bjorn-UL30A:~/Desktop$ update-mime-database /home/bjorn/.local/share/mime/
That should be it. Check properties of a .ipynb file to see the new mime type.
Obtaining a nice icon
I downloaded "ipython-3.1.0.zip" from https://pypi.python.org/pypi/ipython/3.1.0
inside the zip file (/ipython-3.1.0/docs/resources/) there is a nice svg icon called "ipynb_icon_512x512.svg"
Adding an icon the the new mime type
I renamed the icon file above to:
application-x-ipynb+json.svg
Now put this file where you file manager can find it. I tried with:
/home/bjorn/.local/share/icons/hicolor/scalable/mimetypes
I had to create the sub folders /scalable/mimetypes/
bjorn@bjorn-UL30A:~/Desktop$ nemo -qq
nautilus -qq
Then restart Nemo using the "Files" icon in the unity launcher.
This worked well for me, this is a notebook on my desktop:
Right clicking on this file gives:
Why?
Why did I choose /home/bjorn/.local/share/icons/hicolor/scalable/mimetypes
as the location for the icon?
Trial and error!
They say here that the "hicolor" icon theme is a fallback theme for icons. I looked in /home/bjorn/.local/share/icons/ and I had only a folder there called hicolor. I wanted to put the icon in my home folder (see below).
Icon themes have an index.theme file that determines where they look for the actual icon files. This file is located in /usr/share/icons/hicolor
As my icon is a scalable (svg) I looked for and found the entry "scalable/mimetypes", so it would make sense to use this location.
I didnt want to put the icon in /usr/share/icons/hicolor/scalable/mimetypes since I would loose the icon when I upgrade or reinstall Ubuntu.
Apparently /home/bjorn/.local/share/icons/hicolor/scalable/mimetypes works just as well.
Hope this can help !
Other useful resources: