How to run symlink'ed executable application from Desktop while using GNOME Shell?

I have Ubuntu 20.04 LTS installed with default GNOME Shell.

Then I have created symlink for some application on the ~/Desktop folder with

ln -s /usr/bin/xclock ~/Desktop/xclock

( the xclock is just an example, it is ELF binary executable:

$ file /usr/bin/xclock /usr/bin/xclock: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=f87335aa6570ba055b8c02492cafd6def2836a30, stripped

)

Now it looks like shown below:

xclock symlink

Clicking on this file does nothing, the execution bit is already set. There is no "Mark as Trusted" in the drop-down menu.

How can I launch this symlink while avoiding creating special .desktop-file for its linked executable?


You probably can't until the Gnome Shell Desktop Icons is developed to allow for directly running executables (which, probably, they shouldn't, but that is another discussion and a matter of opinion ;)). You will need to stick to a .desktop file for now.


I have found solution myself - we need to create special proxy .desktop file launcher and then select it in Open With as default application.

Warning: be careful with the ELF or symlink which you are trying to launch this way. It may harm your system if you got it from untrusted third-party.

Steps to be done:

  1. Create .desktop file to provide new file-association for ELF binaries:

     mkdir -p ~/.local/share/applications
     cat << EOF > ~/.local/share/applications/exec.desktop
     [Desktop Entry]
     Name=Run binary executable
     Exec=sh -c %f
     Terminal=false
     Type=Application
     EOF
    
  2. Select this application as default launcher - select Open with Other Application and set this newly created Run binary executable as default launcher.

  3. Double click on just created symlink to launch linked executable.

Notes:

  1. this is a universal fix for GNOME Shell, Unity, Cinnamon, Xfce, and MATE (on 18.04 LTS and newer).
  2. this fix also work for ELF files copied to the Desktop or any location managed by Nautilus (even from Nautilus itself).
  3. for Ubuntu MATE with its Caja file-manager this issue is reported to Launchpad as bug 1877591