I appreciate that this is a similar question to others, but I am unable to ask any questions as I don't have 50 reputation. I have tried to follow Desktop shortcut for terminal command
Ubuntu 20.04.4 LTS does not allow me to right click on Desktop to create a new file (only New Folder). I ran sudo gedit from terminal, and created the following;
[Desktop Entry]
Name=Jupyter Notebook
Exec=jupyter notebook
Terminal=true
Type=Application
Icon=/usr/share/icons/HighContrast/32x32/devices/pda.png
I saved the file to Desktop, and it appears with a cog icon and my filename > jupyter.desktop
I then change the permissions from terminal to executable, chmod +x (later to +rwx as it doesn't work)
If I attempt to click on the file, all it does is open it in gedit.
If I go to terminal and try to run
./jupyter.desktop
./jupyter.desktop: line 1: [Desktop: command not found
./jupyter.desktop: line 2: Notebook: command not found
./jupyter.desktop: line 3: notebook: command not found
NB I have added 'quotes' to lines 2 and 3 (Name='Launcher Name' and Exec='exec param'), but I still get line 1 error, so I don't know if it correct to add the quotes or not!
I have been referring to this as a Shortcut (yup, I come from MS), but think it is more correct to say Launcher?? Out of interest, is the .desktop mandatory, or could I have no extension, or even .lnk?
I would very much appreciate some help. Thank you
>>>> EDIT after the very useful information from @vanadium >>>
I do not think it is possible to create a .desktop file in a subdirectory of XDG_DATA_DIRS, at least, my attempts to 'get a result' in the Application Explorer failed. It is however noted that the applications shown appear to be cached, as I believe I had experiences that were not immediate. It also appears that the .desktop files are somehow validated, as I get the impression that invalid information will stop the application being shown.
You will have guessed that I am trying to create a Jupyter Notebook shortcut. The reason for doing this was to specify my working directory. During my journey, I found that it appears my installation of notebook actually created a .desktop within ~/.local/share/applications. I had attempted to modify Exec=/home/myhome/my_working_directory/jupyter-notebook %f but this failed, leading me to the conclusion regarding validation.
On further investigation, I found I could use --notebook-dir, and so my final solution is to modify ~/.local/share/applications/jupyter-notebook.desktop
[Desktop Entry]
Name=Jupyter Notebook
Comment=Run Jupyter Notebook
Exec=jupyter-notebook --notebook-dir="/home/myhome/my_working_directory" %f
Terminal=true
Type=Application
Icon=notebook
StartupNotify=true
MimeType=application/x-ipynb+json;
Categories=Development;Education;
Keywords=python;
Hopefully the question, and great information from @vanadium, will be useful to others in the future (it is a shame some old questions cannot be deprecated, as they may steer others down the wrong path ...pun almost intended)
Further EDIT, good references >>>> https://www.howtogeek.com/445303/how-to-create-desktop-shortcuts-on-ubuntu/
https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html