In Ubuntu 18.04, when the user clicks on a custom desktop file, the program displays the message that the application launches is not trusted and launching it may be unsafe. The desktop also does not display the correct icon for the desktop file.
How is it possible to mark the application launches desktop file as trusted so that the message does not get displayed, and the ICON is also displayed on the desktop.
I tried using
chmod +x *.desktop
as suggested in some queries but this does not seem to work in 18.04.
None of the answers provided up to this point have included information about how you can do this in a non-interactive manner. What if I want to script the creation of a launcher and make it trusted without having to click on it?
This usage case is already addressed in this question with this answer. I'm duplicating this information here because this question was much easier to find, and it is not strictly a duplicate because the question here is larger in scope.
To set a launcher as trusted from the command line, run:
With that done, press F5 on the desktop or in the current folder to refresh the view. The launcher should now be trusted.
There are certain conditions that must be met (ownership, running programs, running gio as the correct user). See Sander's answer for the full list.