30

I have just created a .desktop shortcut on my desktop to launch a shell scrip. The script itself works fine, but its shortcut that doesn't display the icon and double-clicking on it just displays its content in gedit:

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/home/alvaro/Desktop/Laptop_screen_config.sh
Name=Screen_config
Icon=/home/alvaro/Desktop/Ubuntu/screen.png

It is allowed to execute as a program in its permissions, so that's not an issue:

File permissions

Does anyone have any ideas why this is happening? Any help would be greatly appreciated!

6
  • Create a folder on your Desktop called TEST, or whatever. If you move the .desktop file into that TEST folder, does it work then?
    – heynnema
    May 8, 2020 at 14:41
  • No, same behaviour inside a folder
    – Alvaro
    May 8, 2020 at 15:05
  • Move your .desktop file into ~/.local/share/applications/, then hit the Super key and type the name of the shortcut, and see if it works then. If not, move the .sh file into your Documents folder, edit the .desktop file, and retry. Make sure the .sh file is executable. (.desktop files, and files on the Desktop, work strangely in 19.xx and higher).
    – heynnema
    May 8, 2020 at 15:12
  • Thanks for the answer, that way the .desktop file can run (still doesn't display the icon though). However, the point was to have a shortcut in the desktop, can't believe this is so difficult
    – Alvaro
    May 8, 2020 at 15:29
  • You've given terminal false, So the script might have executed and completed. Is it throwing any error by the way? Dec 2, 2020 at 17:22

12 Answers 12

28

Make sure you've allowed launching and, maybe, selected it as Run Software on Open With tab.

enter image description here

Configure your shortcut the next way:

[Desktop Entry]
Version=1.0
Name=Firefox Web Browser
Comment=Browse the World Wide Web
GenericName=Web Browser
Keywords=Internet;WWW;Browser;Web;Explorer
Exec=/home/alvaro/Desktop/Laptop_screen_config.sh
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/home/alvaro/Desktop/Ubuntu/screen.png
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
StartupNotify=true
Actions=new-window;new-private-window;

I've copied firefox's shortcut settings and modified them to allow to launch your script. With this it allows changing its launching configuration. You could remove unneeded options and check if it works without them.

4
  • 9
    I have tried to set "Run Software" as the default application with the same result and unfortunately I don't have the option "Allow launching" when I do right clic on it...
    – Alvaro
    May 8, 2020 at 14:52
  • I have used your proposal using the firefox config but same behaviour. When I open it from the desktop it just opens the file and if I open it from nautilus (having allowed to run it in preferences/behaviour) it just open the terminal briefly but doesn't run the script.
    – Alvaro
    May 8, 2020 at 15:13
  • I have tried exactly your config but unfortunately I don't have the Allow launching option when I do right click on it... any idea why this could be?
    – Alvaro
    May 8, 2020 at 15:21
  • @Alvaro consider using Gnome desktop instead of Unity. As it seems, Unity does not have this ability. Make a screenshot of your desktop with launcher visible to see what it should be.
    – Gryu
    May 19, 2020 at 10:14
17
  • Move the .desktop file into ~/.local/share/applications/ and make executable if need be.

  • Move the .sh and .png files into ~/Documents and make sure the .sh is executable.

  • Modify your .desktop file for the new locations for the .sh and .png files.

  • Hit the Super key and type the name of your shortcut.

  • You can save your .desktop file as a favorite in the Dock for quick access.

Enjoy!

2
  • 5
    This option has worked for me but the point was to have the shortcut on the desktop which seems to be the real issue
    – Alvaro
    May 8, 2020 at 15:49
  • 3
    @Alvaro As far as I know, .desktop files won't work from the Desktop in 20.04.
    – heynnema
    May 30, 2020 at 16:57
10

This was hidden in the comments but it is absolutely the only way to make it work on Ubuntu 20.04 LTS after the latest updates:

This still works (going back several Ubuntu versions):

Copy the application launcher in your home directory (~/application.desktop)

At the command line (in a terminal) run "sudo desktop-file-install application.desktop" (without the quotes).

This checks the syntax of the launcher and (if it has no errors) installs it into /usr/share/applications

Open nautilus in /usr/share/applications.

Find the icon for the launcher (application.desktop) and drag the icon to some convenient location in the dash. This locks the launcher to the dash.

4
  • 3
    This is a good first answer but could use some formatting. eg use sudo desktop-file-install application.desktop instead of "sudo desktop-file-install application.desktop". More importantly though a few screen shots would make the answer easier for people to try out on their own machines. Dec 31, 2020 at 22:10
  • 1
    desktop-file-install also validates the .desktop file which is really important to catch potential errors/issues. desktop-file-validate is the dedicated command for validation.
    – Junaid
    Mar 6, 2021 at 21:28
  • Drag&Drop in nautilus fails for me because of permission issues, what works is copying it on command line. Apr 9, 2021 at 11:38
  • This is great but I have a blank icon on my dock... any way to put any kind of icon?
    – BrianBlaze
    Dec 29, 2021 at 18:25
7

I had the same issue and I was struggling for quite while

Issues that I was facing:

  1. Icons were not showing
  2. Double Clicking an a desktop shortcut would open a text editor instead of launching the application

How I solved this problem?

Right click the icon > Properties > Permissions

Set Group access to Read and Write and Others Access to Read-only and check Execute.

Shortcut Icon permission settings

and select Allow Launching

Allow Launching

Now You icon will appear and you can double click to run the program

enter image description here

2
  • Nicely explained with the images.
    – PhoneixS
    Oct 1, 2020 at 8:53
  • 3
    Setting the access for others to "Read-Only" seems to be the key for the "Allow Launching"-menu option even showing. That's the piece of the puzzle that was missing from the other answers. I would be interested in their reason for hiding the option and making the transition seemingly as convoluted as possible. At any rate: +1
    – Kakturus
    Jan 28, 2021 at 13:11
5

None of the above worked for me.

This still works (going back several Ubuntu versions):

  1. Copy the application launcher in your home directory (~/application.desktop)
  2. At the command line (in a terminal) run "sudo desktop-file-install application.desktop" (without the quotes). This checks the syntax of the launcher and (if it has no errors) installs it into /usr/share/applications
  3. Open nautilus in /usr/share/applications.
  4. Find the icon for the launcher (application.desktop) and drag the icon to some convenient location in the dash. This locks the launcher to the dash.
2
  • same here. All answers other than, @Mr_Display_Name is just bogus. In case of Ubuntu 20.04 OS.
    – Mithun B
    Nov 6, 2020 at 12:07
  • Changing the "Exec" command works for me. Using Ubuntu 22.04.
    – Dante
    Jun 23 at 12:35
4

How I solved it. None of these tips worked for me, yet I had a manually created shortcut to Spyder on my desktop that worked. Like many of you, "Allow Launching" did not appear in the right-click context menus. My problem was in the EXEC= field, and that I used the ~ character rather than the real path.

2

First, set the .desktop file as 'trusted':

$ gio set <entry.desktop> metadata::trusted true

Then:

$ sudo chmod +x <entry.desktop>
1

My final solution (after fixing permissions, ownership, typos, etc..) was to make a copy of the launcher from the desktop back on to the desktop. No other changes. The copy (which had identical ownership and permissions) had the "Allow Launching" context menu item; the original did not.

1
  • Similar experience. Currently I'm able to go to terminal and run cp myprogram.desktop myprogram2.desktop, and then the original one (myprogram.desktop) starts working again, as well as the new one having "Allow Launching". Then it fails again after like 1 day and I can repeat the same process to get it to work again...
    – krubo
    Sep 4, 2021 at 19:32
1

The Allow Launching was not appearing for me at all. There is subtle but important point made by Kakturus above. I am re-stating it below. The access for others needs to be Read-only, then the Allow Launching will appear!

Setting the access for others to "Read-Only" seems to be the key for the "Allow Launching"-menu option even showing. That's the piece of the puzzle that was missing from the other answers. I would be interested in their reason for hiding the option and making the transition seemingly as convoluted as possible. At any rate: +1 – Kakturus Jan 28 at 13:11

1
1

Just type on terminal, at the path where the .desktop is located "chmod -R 755 ."(as . is making reference to the path where you are at the moment of typing), advice, do it on /Desktop to make sure futures icons will get those permissions. Take care

0

Sorry if this method doesn't work for you. In properties box of the file you must change Others access to Read only to see the Allow launching in the dropdown menu. May it help.

0

I've the same problem but my starter is created by a bash script that installs an application. The starters is created but is not launchable with Ubuntu 20.04 (it works fine with 18.04). So, is there any command such as "chmod" to include in my script and to apply to the starter file that makes it "launchable"? BTW, on Ubunru 20.04, this problem occurs only with Gnome and not with both Cinnamon and Mate!!! Thank you in advance.

2
  • As you already know about Cinnamon and MATE, then maybe it is time to switch to one of them?
    – N0rbert
    Mar 7, 2021 at 7:22
  • Sure, but since my script installs an application, I'd like to make it running the same way whatever GUI the user runs (Cinnamon, Mate, Lxde... AND Gnome 3) on its system. So, I'm looking for the command that the Gnome 3 GUI uses to make a starter launchable when you use the GUI menu option as described below by Gyru and Ashish. I bet it's not a secret but I didn't find any documentation on this subject yet.
    – Fnux
    Mar 7, 2021 at 22:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.