37

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!

Lorenz Keel
  • 9,511
Alvaro
  • 373

14 Answers14

32

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.

Gryu
  • 8,002
  • 9
  • 37
  • 53
20
  • 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!

heynnema
  • 73,649
17

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.

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.

Steve Owens
  • 271
  • 2
  • 3
8

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

Ashish
  • 201
7

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.

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.
3

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

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

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.

thong
  • 1
0

Had the same issue when after installing JetBrains Toolbox and IDEs on Ubuntu 23.10.

For me, the error was executing the toolbox install script using sudo which is not recommended. As a result, the application and .desktop files were installed in /root/.local/share instead of in ~/.local/share and the programs would not show in the application launcher.

Fixed the issue by deleting /root/.local/share/JetBrains and the false /root/.local/share/applications/*.desktop files and install the Toolbox and IDEs again without using sudo

0

Not exactly this case, but I just creted and solved this problem for myself.

I stoppped seeing this "Allow Launching" function after I did this stupid thing:

sudo chmod -R 777 ~

It also crashed a few more things in my system, for example, Steam (but just reinstalation helped).

When I changed the permissions of the ~/Desktop to 744, the "Allow Launching" function reappeared.

So this may be not relevant for directly this case, but may give a clue for the troubleshooting for whoever faces this issue in the future.

0

In my case, I had a similar issue with "AWS VPN Client" after upgrading to Ubuntu 24.04 LTS (it was working previously in 23.10, but stopped working after upgrade).

To fix it:

  • I've changed permission to 775
  • Then, in the "Exec", I've put double quotes in the whole thing, instead of escaping espaces with "\", i.e, used to be Exec=/opt/awsvpnclient/AWS\ VPN\ Client, and I've changed to Exec="/opt/awsvpnclient/AWS VPN Client"

And, to test it, to launch from terminal: gtk-launch awsvpnclient.desktop (so you can see any issue related to your desktop file)