Launch script with double click don't work

Solution 1:

Some will say: "move to another desktop environment".

In the Gnome desktop environment, used by Ubuntu, the ability to run any program by double-clicking on it in the file manager is deprecated. It is indeed handy in some use cases. In other use cases, it can be confusing for users and for sure, it can be a security nightmare. Which is probably an important reason why it is deprecated.

It actually remains possible to set that up, however, it is not anymore set up by default.

  • If you are a developer needing to run an application during development, open a terminal. Enter the name of the program once (use Tab for command completion. Then use arrow up to repeat the command.
  • If you are an end user needing to run some application, then install it properly. Install or link the executable in your ~/bin or ~/.local/bin directory. Run it from the terminal just by typing the name, or create a launcher to it in ~/.local/share/applications. Then, you can run it from the application overview, and even pin it to the dock for quick access.

Still, you could set up the ability to run files from the file manager by setting up a .desktop launcher that runs a file you provided as an argument. A .desktop launcher with the line Exec=gnome-terminal -- %f would open Gnome Terminal and (try to) run the file name provided, represented by the %f. If it is a script, you will see it running in the terminal. If it is a graphical application, Gnome terminal will briefly load, but disappear once the graphical application has started. A minimal .desktop launcher for this is:

[Desktop Entry]
Name=Generic application runner
Comment=Runs executable files
Exec=gnome-terminal -- %f
Type=Application    

With the .desktop file installed in ~/.local/share/applications, you can run any program by right-clicking and selecting "Open with...". You can associate files with a specific extension, e.g. .sh for scripts, to that launcher so it runs upon double click.

Alternatively, you will need to at least switch to a file manager still supporting the feature, or switch to another desktop environmemt like Mate or Xfce.