25

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.

pim
  • 3,350
arun nath
  • 381
  • 1
  • 3
  • 6

8 Answers8

21

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:

gio set /path/to/your/launcher.desktop "metadata::trusted" yes

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.

Vitor Abella
  • 8,015
  • 16
  • 63
  • 115
b_laoshi
  • 4,868
  • 4
  • 26
  • 49
12
  • First set the executable bit of the .desktop file like you did already. You may also do this by right-clicking the file in the file manager and setting the executable property on the "Permissions" tab of the "Properties" dialog if you find that easier than the command line.
  • Now try launching the icon again by double-clicking it. Again, a dialog appears, but note: it is a different dialog. This time, select the "Launch and trust" button, and your desktop file will now turn into a functional launcher with the right icon.
vanadium
  • 97,564
11

after hours of searching, I finally found what was causing my problem with the .desktop files never being trusted and not showing icons:

Change the owner to your user name (mine was set to root which was breaking things):

sudo chown $USER:$USER ~/.local/share/gvfs-metadata/home*

credit to @George Udosen who helped me fix it: GVFS-WARNING **: can't init metadata tree /home/user/.local/share/gvfs-metadata/home: open: Permission denied

Jared
  • 361
1

Set the proper user name and group name for the particular desktop file (chown) . Now try to launch again, dialog appears select the "Launch and trust" button.

1

And just to add to b_laoshi 's answer - after updating from 16.04 to 18.04 I had a desktop full of steam links I didn't want to have to open each game and then quit to trust them

for i in ~/Desktop/*.desktop; do    gio set "$i" "metadata::trusted" yes ;done

You should never trust code from stackoverflow without being sure what it does:

  • set "$i" in turn to the full path of each file on your desktop named desktop
  • runs

    gio set </home/path/to/your/whatever.desktop> "metadata::trusted" yes
    

    for each

  • done marks the end of the loop
pomsky
  • 70,557
Greg
  • 1,422
1

I created a .desktop file, and it was blocked. Then I made it executable, and then I got a pop-up which allowed me to start the application. Finally, I copied the desktop file to /usr/share/applications Now it starts without a pop-up.

0

None of these worked for me except to delete gvfs-metadata

sudo rm ~/.local/share/gvfs-metadata/home
pomsky
  • 70,557
Paul B
  • 1
0

This worked perfectly for me: just right-click, select permissions, and check "Allow Executing of This Program," or something similar.

Maimas2
  • 101