2

On Ubuntu 20.04.2 LTS I'm trying to create a desktop icon for some applications. I tried to follow this tutorial How to create desktop shortcut launcher on Ubuntu 20.04 Focal Fossa Linux . The first approach (using nautilus) does not fit for me, as I some of those applications are not there (for example Pycharm) and some other are created by me. So I tried the second approach, and I created a ~/Desktop/PyCharm.desktop file like this one:

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/Programs/pycharm-community-2021.1.3/bin/pycharm.sh
Name=PyCharm
Comment=PyCharm
Icon=/Programs/pycharm-community-2021.1.3/bin/pycharm.png

but when I right click on the file, I don't have the option Allow launching. If I check the properties, I have all the permissions and the Allow execution checkbox is checked.
What am I missing?

Deffo
  • 181

2 Answers2

2

Just found the mistake...the file is correct (the .sh is needed, as it is what I want to launch). The error is that I should have written Exec=/home/deffo/Programs/pycharm-community-2021.1.3/bin/pycharm.sh (also the Icon path is wrong of course). Now I am able to launch it

Deffo
  • 181
0

PyCharm is not a shell script. Take the .sh off the filename at the end of the exec=.. line in your .desktop file.

Bash has its own scripting language. Those files end with .sh, but most linux apps are written in other languages. The executables, at least the bigger ones like PyCharm, will usually not have an extension.

If you want to be sure, just cd to the directory that you have as the parent folder, and type ls or la. You will get a list of the folder's contents, among which will be the correctly named file.

EDIT: Since there is an sh script, you should check its contents to see where your executable is located. cat <filepath/filename> | less.

Once you find the actual location of the executable, update your [desktop entry].

EDIT 2: The quickest way for you to get the icon is to run sudo snap install pycharm-community --classic. When getting software on Ubuntu, unless you have a good reason not to, you should always get it via package manager. Ubuntu comes with apt and snap, although you will end up with others as time goes on.

Package managers are constantly watching your system, checking that you have all the dependencies, and auto updating your versions in unison, so that an update to one app doesn't destroy 5 others.

When you install via tarball (.tar.gz file), you are on your own.

If you install via snap, check the contents of your tarball for an uninstall script. That one may be a .sh file. Run it before snap install. (optional but advisable)

Nate T
  • 1,590