2

I have a desktop icon that does not work. When I attempt to use it I get the error

Untrusted Desktop File This desktop file is not trusted, it cannot be launched. To enable launching right-click, then: Enable "Allow Launching"

I do not get this "Allow Launching" menu item when:

  1. I right click on the icon in the desktop
  2. I right click on its file in Dolphin
  3. I right click on this file in the "File Manager"

So I attempted to do it from the command line by using the instructions on this webpage: How to mark a .desktop file as trusted from command line on Ubuntu 18.04? . Since I have many such untrusted launcher links I used this command sequence, and got this response:

$ chmod u+xrw /home/stephen/Desktop/*.desktop
$ chmod g+xrw /home/stephen/Desktop/*.desktop
$ chmod o+xr /home/stephen/Desktop/*.desktop
$ gio set "/home/stephen/Desktop/*.desktop" "metadata::trusted" yes
gio: Setting attribute metadata::trusted not supported

I got the same error when I gave gio a specific file instead of the * wildcard character, also when I attempted to execute gio as root.

What is the correct attribute to give the gio command? In which file browsers should the "Allow Launching" menu item appear?

My OS is Ubuntu 22.04 jammy

Here is one of the .desktop files I have this trouble with:

[Desktop Entry]
Comment=Powerful yet simple to use screenshot software.
Comment=Powerful yet simple to use screenshot software.
Comment[en_US]=Powerful yet simple to use screenshot software.
Exec=flameshot launcher
GenericName=
GenericName=
GenericName[en_US]=
Icon=flameshot
MimeType=
Name=Flameshot (Snappy Edition)
Name=Flameshot (Snappy Edition)
Path=
StartupNotify=false
Terminal=false
TerminalOptions=
Type=Application
Version=1.0
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=

I followed the recommendations ubfan1 made in the comments on Sept 6, 2022. The results:

stephen@stephen:~$ desktop-file-validate /home/stephen/Desktop/Flameshot.desktop
/home/stephen/Desktop/Flameshot.desktop: error: file contains multiple keys named "Comment" in group "Desktop Entry"
/home/stephen/Desktop/Flameshot.desktop: error: file contains multiple keys named "GenericName" in group "Desktop Entry"
/home/stephen/Desktop/Flameshot.desktop: error: file contains multiple keys named "Name" in group "Desktop Entry"
/home/stephen/Desktop/Flameshot.desktop: warning: value "" for key "Path" in group "Desktop Entry" does not look like an absolute path
/home/stephen/Desktop/Flameshot.desktop: warning: key "TerminalOptions" in group "Desktop Entry" is deprecated

What should the Path key be set to? Not knowing this, and also because it was just a warning, I edited the rest of the file accordingly. This is the result of those edits:

[Desktop Entry]
Comment=Powerful yet simple to use screenshot software.
Comment[en_US]=Powerful yet simple to use screenshot software.
Exec=flameshot launcher
GenericName=
GenericName[en_US]=
Icon=flameshot
MimeType=
Name=Flameshot (Snappy Edition)
Path=
StartupNotify=false
Terminal=false
Type=Application
Version=1.0
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-Desktop-File-Install-Version=0.26
X-KDE-SubstituteUID=false
X-KDE-Username=

Now I get these results:

stephen@stephen:~$ desktop-file-validate /home/stephen/Desktop/Flameshot.desktop
/home/stephen/Desktop/Flameshot.desktop: warning: value "" for key "Path" in group "Desktop Entry" does not look like an absolute path
stephen@stephen:~$ sudo desktop-file-install /home/stephen/Desktop/Flameshot.desktop
/usr/share/applications/Flameshot.desktop: warning: value "" for key "Path" in group "Desktop Entry" does not look like an absolute path
stephen@stephen:~$ sudo desktop-file-edit /home/stephen/Desktop/Flameshot.desktop
/home/stephen/Desktop/Flameshot.desktop: warning: value "" for key "Path" in group "Desktop Entry" does not look like an absolute path

Still the "Allow Launching" menu item does not appear.

Then I discovered that the Flameshot.desktop is no longer executable. So I used Dolphin to make it so. After doing this I found the act of making it executable caused the content of Flameshot.desktop to revert to what I started with above. The duplicate key entries were reintroduced, and I ended up right where I started from.

Maybe the Path key warning was more important than I assumed. Before I try again I need to know what to set it to. Any other suggestions would also be much appreciated.

I created a spreadsheet to compare the results of the " strace gio set" command done in the test account, which is new temporary account created for testing in which I am able to create working desktop icons, and the stephen account, which is the main account, and the one created during Ubuntu installation, where I am not able to. It can be downloaded from:

https://www.mediafire.com/file/xz4dy7280wfx3u8/giosetenablecomparison.ods/file

Column A is the result of the command in the main account, and Column B is the result in the test account. The results are closely comparable until row 59. In the test account this shows "close(3)" for the main account, and "close(3) = 0" in the test account.

In the stephen account the output ends at row 59. In the test account the output continues all the way to row 516.

I do not know what all this output means. It appears to me that some error is ending the process prematurely in the stephen account. Someone here can see what has gone wrong, and suggest a solution.

The old computer I migrated from has a Pop!_OS 21.04. The new computer I migrated to, and have this icon trouble with, has Ubuntu 22.04. When I did the migration I copied all the binaries in /opt, and all files in /home. By copying all files in /opt I hoped to spare myself the time, and effort, to do all the software installations again. I know there are binaries elsewhere such as in /user/bin, and /snap. I did not copy these, and intended to install these in the new computer using installation files. I knew there would be broken links in the /Desktop directory until the apps these are linked to are installed. I think now this may have been a mistake, and that all should have been installed from installation files in the new computer.

The result of the commands requested by steeldriver in his comment:

stephen@stephen:~$ echo $DBUS_SESSION_BUS_ADDRESS
unix:path=/run/user/1000/bus
stephen@stephen:~$ id -u
1000
11
  • 1
    You can always look at the metadata info for the file by running gio info filename.desktop and it will show you if it supports metadata::trusted or not. When I was just looking at my files they say that metadata::trusted true but I don't know if true or yes will make any difference.
    – Terrance
    Commented Sep 4, 2022 at 3:00
  • Please post the desktop file, it might have errors.
    – ubfan1
    Commented Sep 4, 2022 at 4:09
  • The situation is that I am migrating to a new computer. This .desktop file was migrated over a local network into the same directory path in the new computer. The command "rsync -az ...." was used to do this. This same file worked on the computer being migrated from. In the new computer I did the "gio info" command on one of the .desktop files in question. In its output I did not see any attribute that began with "metadata::" Does that mean metadata is not supported on this .desktoip file? If so how did it lose this support in the transfer? Is there a way it can be regained?
    – Stephen
    Commented Sep 4, 2022 at 15:58
  • 1
    Where does Ubuntu store an .desktop file's metadata, particularly in regard to whether it is a trusted launcher? Is it a file that can be hacked? Or is it in the .desktop file itself?
    – Stephen
    Commented Sep 5, 2022 at 17:30
  • Try running desktop-file-validate, and desktop-file-install and desktop-file edit on the desktop file. At least you can correct any errors, then the right click for the menu may contain the "Allow launching" choice. Locations like .local/share/gvfs-metadata are not helpful, files are binary. .local/share/applications and /usr/share/applications seem to have other standard desktop files.
    – ubfan1
    Commented Sep 5, 2022 at 21:18

2 Answers 2

2
gio set "/home/stephen/Desktop/*.desktop" "metadata::trusted" yes

is not correct. 3 issues:

  • you need to use dbus-launch. If dbus-launch is not installed first do:

    sudo apt install dbus-x11
    
  • You can not use wildcards.

  • it is "true" not "yes" as of Ubuntu 20.04.

The command:

dbus-launch gio set /home/stephen/Desktop/{name}.desktop "metadata::trusted" true

(where {name} needs to be replaced by the actual name)

2
  • The command: "dbus-launch gio set "/home/stephen/Desktop/Flameshot.desktop" "metadata::trusted" true" did execute, and without error. But the "Flameshot.desktop" icon did not change, this icon is still grayed out, and when right clicked the "Allow Launching" menu item still does not appear. The output of the command: "gio info -a 'metadata::*' /home/stephen/Desktop/Flameshot.desktop" does output the line: "metadata::trusted: true". It appears that the gio command executes the same regardless of whether "dbus-launch" is before it in the command line.
    – Stephen
    Commented Feb 2, 2023 at 19:17
  • These commands are entered directly in the GNOME Terminal, and not remotely through TTY, or SSH.
    – Stephen
    Commented Feb 2, 2023 at 19:18
2

The "Allow Launching" menu item did not appear because the directory: "~/Desktop" was writable by others. I had to find, and analyze, gnu source code to find this out. The key to it was line 200 in file:

/usr/share/gnome-shell/extensions/ding(at)rastersoft.com/fileItemMenu.js" .

(substitute (at) for @)

This is:

if (fileItem.isValidDesktopFile && !this._desktopManager.writableByOthers && !fileItem.writableByOthers && (selectedItemsNum == 1 )) {

Because the directory "~/Desktop" was writable by others, the term "!this._desktopManager.writableByOthers" was false, and so the menu item did not appear.

The requirement that the "~/Desktop" directory not have writable by others permission is not documented, and it needs to be. It would have saved me a lot of time had it been.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .