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,280
arun nath
  • 381
  • https://askubuntu.com/questions/419610/permission-of-a-desktop-file – Rinzwind Jul 16 '18 at 14:38
  • I too am having this exact same issue, every time I click the .desktop file, it asks to "trust and launch", and it opens, but it asks me the same thing every time (on the same file), and the icon never updates. The weird thing is, I think it started around the time I had to restart X11 (startX) because I had an app freak out when it was full screen. Did you ever find a solution to this? – Jared Aug 18 '18 at 21:27

8 Answers8

20

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
  • 7,537
b_laoshi
  • 4,660
  • 4
  • 25
  • 46
  • It hasn't worked to me at 18.04. The target .desktop file stay with the Allow executing file as program checkbox unmarked in properties menu – artu-hnrq Mar 22 '20 at 18:33
  • I had a new .desktop file as launcher on desktop, with correct icon path and everything, it ran the executable and all (so it was trusted) - and it wouldn't show the icon, until I hit F5 on the desktop; thanks for this tip! – sdaau Apr 13 '20 at 08:31
  • This has worked for me, but I had to change yes to true (and the chmod +x is also required) – romaia Feb 21 '22 at 02:08
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
  • 88,010
  • 1
    Thanks for your response. My problem is that I do not want any message to appear when I click on the icon. How do you mark the application as trusted by default? The icon also needs to be displayed. – arun nath Jul 17 '18 at 07:37
  • Please read again carefully what I wrote, and first try it out. That is the procedure to mark a launcher as "trusted". Once you have done that, the launcher will work as expected and immediately launch your application. You asked "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." and this is the answer on "how". – vanadium Jul 17 '18 at 10:04
  • I am able to launch the application. All that works well. But the desktop file does not turn into the ICON. Also when I close the application, and try to launch it again, the message pops up again. There does not seem to be a way to do away this the pop up message once and for all. Keeps popping up all the time. I hope I am not missing something here. – arun nath Jul 17 '18 at 10:44
  • You mean, you are able to launch the application from your untrusted launcher after answering the dialogs, but then the launcher does not become "trusted"? That is not normal behavior. On my system, I need to do this once, then the launcher is "trusted" and this is being remembered. – vanadium Jul 17 '18 at 11:04
  • That's right it does not seem to remember it anymore. It used to work like what you had suggested. The latest series of Ubuntu 18.04 updates seems to have broken it. – arun nath Jul 17 '18 at 13:48
  • I fully updated my system (18.04) one minute ago and checked again: it worked. Check with "ls -l ~/Desktop | grep .desktop". Is the executable bit (still) set? – vanadium Jul 17 '18 at 14:17
  • so what was wrong for me, is that the desktop files were owned by root. so I just did sudo chown $USER:$USER ~/Desktop/* – user27221 Sep 03 '21 at 14:06
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
  • 351
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
    I had the problem that there was already the right user and group set. Sadly not really as I installed Ubuntu ontop again and remounted the home directory with the same user name. Turned out that a user with the same name is not per se the same user. With sudo chown -R myuser:myuser ~/everything worked without any problems and no need to restart. – Sebastian Barth Jun 22 '19 at 16:50
  • I have the same problem. In addition, if I double click on the .desktop file in /home/${users}/.local/share/applications/EclipseWeb.desktop when using Nautilus,I get a message stating:

    Error launching application

    and I can find no information to help me interpret the message.

    – Jonathan Apr 21 '20 at 17:31
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
  • 68,507
Greg
  • 1,413
  • I had the same problem and neither gio nor chown would change the group or owner. – Jonathan Apr 19 '20 at 00:09
  • gio won't change the owner or group - it just tells gnome to trust it. check the owner/group with stat filename, if chown isn't working check any error messages, you can only run it as root (ie with sudo) and some filesystems (eg file shares, SD cards, windows disks) won't support it – Greg Apr 20 '20 at 01:57
  • Thanks, It worked for me – mss Jul 18 '20 at 20:51
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.

Tejas Lotlikar
  • 2,945
  • 5
  • 17
  • 26
0

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

sudo rm ~/.local/share/gvfs-metadata/home
pomsky
  • 68,507
Paul B
  • 1
  • 2
    @Paul Is there any specific reason that you ran the rm command to remove a file inside your home directory with sudo? Usually running commands willy-nilly with sudo when it's not necessary is not a good idea. It might cause issue with file permissions and lead to a breakage. – pomsky Jul 11 '20 at 12:36
  • I suspect there were permission issues in my system (which were causing the initial issue), I suppose I should have tried it without sudo first, but was frustrated by that stage as none of the other solutions I had found worked and wanted to be sure the command took effect. – Paul B Jul 12 '20 at 20:49
0

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

cs1349459
  • 101