Score:2

Create desktop launcher

us flag

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?

Nate T avatar
it flag
Wait, what is PyCharm.sh?
Deffo avatar
us flag
@NateT it is the executable...when I want to run pycharm from terminal, I cd to */Programs/pycharm-community-2021.1.3* and run `bin/pycharm.sh`
vanadium avatar
cn flag
This .desktop file looks OK. For all clarity, you *can* launch the program by double-clicking the file? You seem to refer to right-clicking instead. Remove the first line. It does not serve any purpose anymore. You could be facing the limitations of the Desktop icons extension in 20.04. Does the launcher appear in the menu and work when you move it to .local/share/applications?
Nate T avatar
it flag
Linux programs like PyCharm aren't built in sh. At least not programs that intend to be loaded onto a variety of OSs. sh is mostly for helper scripts etc. Not saying that it can't be done, just that it usually isn't. Most of Linux is built with C.
Nate T avatar
it flag
The actual will likely be in `/usr/share/bin` or else in `opt`.
Nate T avatar
it flag
You know what, I have an easier method of getting the Icon. Updating answer.. again. XD
Deffo avatar
us flag
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
karel avatar
sa flag
Does this answer your question? [How can I create launchers on my desktop?](https://askubuntu.com/questions/64222/how-can-i-create-launchers-on-my-desktop)
Score:1
us flag

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

Nate T avatar
it flag
Check [this](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/deployment_guide/s1-filesystem-fhs) out. It contains a lot of good info. I'm guessing you will find it useful. The standard applies to nearly all linux distros, Ubuntu included. It is a bit different than Windows, so learning about it early on should save you a lot of time in the near future.
Score:0
it flag

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)

Deffo avatar
us flag
removing .sh did not work. If I move to the parent directory and type `ls` I can see a file named `pycharm.sh`. Also, to run it from terminal I type `./pycharm.sh`
Nate T avatar
it flag
@Deffo Does it run pycharm? If so, it is some sort of launcher script. How did you install PyCharm? if you type `cat <path-to-script>` in the terminal, you can see its contents. the actual location will be hidden within, I guarantee it. Updating answer.
Deffo avatar
us flag
I installed Pycharm from the JetBrains website. I downloaded a .tar.gz, unpacked it and simply run `pycharm.sh` inside a terminal. I just followed the instructions on the Jetbrains website. Anyway, I found out the mistake was the path to the executable...but the .sh extension is needed, as it is what I want to launch (I know it is a launcher script, and that's exactly what I want to launch)
Nate T avatar
it flag
Check the tarball to see if there is an uninstall script. Most files will be available on the maker's website. The same file is available, installed by the system itself. In that tar.gz, there are a bunch of files. Each of those files should go in a certain spot in the fs. I promise, I can't overstate the advantages of using a pkg mgr. Only install via tarball if you have no other choice, i.e. you absolutely need a feature from a new release. Btw, if you add --edge to the snap cmd, youll get the newest version (preinstalled), but it hasn't been tested as thoroughly.
Nate T avatar
it flag
As per your last comment.. bad idea but it's your choice. Your turning down the maserati for the Chevy cavalier. Google 'why package managers'. GTG glad you got it fixed. If my answer didn't help, be sure to write your own, so everyone else sees from the front page that it is solved. Happy programming. Snap also has Idea. Install it an you can see which method you prefer. change name to `intellij-idea-community`. vs code as well.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.