Recently the project jupyter added the mime-type to the ipynb files: application/x-ipynb+json, and I'd like to launch easily these files without having to allways launch the terminal command:
cd /path/to/notebook
jupyter notebookSo I've adapted this blog post in order to:
- launch a jupyter-notebook server when double clicking a
ipynbfile - add icon to
ipynbfiles. - create a desktop Launcher to easily launch a jupyter notebook from a default folder or dragging and dropping a file or folder.
Here's how it looks, and see my answer below to understand how to do this.
2 Answers
1. Create a ipynb.xml mime-info file
<mime-info xmlns=' <mime-type type="application/x-ipynb+json"> <comment>IPython Notebook</comment> <glob pattern="*.ipynb"/> </mime-type>
</mime-info>Then store the file in ~/.local/share/mime and update the mime database.
cp ipynb.xml ~/.local/share/mime
update-mime-database ~/.local/share/mime2. Create a jupyter.desktop file
Caution: Edit paths to adapt it to your system and habits.
[Desktop Entry]
Version=1.0
Type=Application
Name=Jupyter
Icon="$HOME/.icons/jupyter-sq-text.svg"
Exec=/path/to/jupyter notebook %F
Path="$HOME/Documents/Notebooks"
Comment=Jupyter notebook
MimeType=application/x-ipynb+json;
Categories=Science;
Terminal=trueThen install the desktop file:
desktop-file-install --dir="$HOME/.local/share/applications" jupyter.desktop3. Add the jupyter icon
I chose the svg version from the design repository of jupyter, and installed in ~/.local/share/icons
wget -o $HOME/.local/share/icons/jupyter-sq-text.svgFinally, link the mime-type icon to the system:
sudo ln -s $HOME/.local/share/icons/jupyter-sq-text.svg /usr/share/icons/gnome/scalable/mimetypes/application-x-ipynb+json.svg
sudo gtk-update-icon-cache /usr/share/icons/gnome/ -fHope that's help!
For running Jupyter notebooks, you may prefer the above method.
Whereas for previewing a notebook, I recommend you take a look at nb-viewer. With it you can preview a Jupyter Notebook with a double click.