How to create a icon on Ubuntu 16.04 desktop that would start a command line app?

EDIT on 27 Aug 2016: Used bash -c in exec line, error message gone but jupyter not starting. Is this even possible on Ubuntu? seems like a lot of effort to implement a simple functionality.

EDIT on 16 Aug 2016: Replaced the ~ with $HOME, but error message persists.

I'm on Ubuntu 16.04 and I'm trying to create a script on the desktop that would start jupyter notebook from a certain directory, say ~/Notebook.

I know how to make it work in terminal, just run jupyter notebook --notebook-dir=~/Notebook, then I'm on my way.

But how to make an icon on the desktop and when I double-click it, it just run that command?

There must be something obvious I'm missing here.

[Desktop Entry]
Version=1.0
Name=Jupyter
Comment=Jupyter Desktop Shortcut
Exec=jupyter notebook --notebook-dir=~/Notebook
Path=~/Notebook
Terminal=true
Type=Application
Icon=~/Downloads/7388996.png

it just reported "There was an error launching the application."

Where should I go from here?

Thanks!


I would suggest you use bash for the Exec key. Try bash -c "~/anaconda2/bin/jupyter notebook --notebook-dir=~/Notebook", or bash -i -c "jupyter notebook --notebook-dir=~/Notebook if you have added the full path to the environmental variables.

Not sure why your entry wouldn't work, but I guess it might be the before "notebook"?

BTW, I wouldn't use a desktop entry for applications like Jupyter Notebook, as I reckon the notebook process still needs to be killed in terminal.


I was using:

Exec=/home/paul/anaconda3/bin/jupyter notebook --notebook-dir=~/Notebook

As suggested in a comment by PaulDong, but I was having problems trying to add a path to the PYTHONPATH.

Now I am using the following (on Ubuntu 16.04):

I have created a jupyter_.sh (in /home/usr/) file with the following:

#!/bin/bash     

# OPTIONAL - add to PYTHONPATH
export PYTHONPATH="${PYTHONPATH}:/path_to_add/

# start notebook at the desired folder
jupyter notebook --notebook-dir '/path_to_notebooks/'

And I have a Jupyter.desktop file with:

[Desktop Entry]
Version=1
Name=Jupyter
Comment=Open jupyter at different dir
Exec=bash -c "~/jupyter_.sh"
Icon=/home/usr/anaconda3/lib/python3.5/site-packages/anaconda_navigator/static/images/jupyter-icon-1024x1024.png
Terminal=true
Type=Application