Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gnome 3 and .desktop files - What exactly does "Allow/Disallow lauching do"?

I know that when creating a .desktop file, one can set the metadata::trusted as true and false, in order to be able to launch the icon as an executable. What is intriguing me however is the fact that:

  1. When right-clicking on the .desktop file and "Allow launching" apparently the only thing it does is to set the metadata::trusted to true. The icon, however, changes, as expected, instantly to the icon described in the .desktop file Icon=.

  2. However when setting the metadata::trusted to either false or true via command-line the icon doesn't seem to change its behavior $ gio set android-studio.desktop metadata::trusted false

Once I refresh the Desktop manually (Alt + F2 >> restart) the environment refreshes and the icon turns to be executable again, BUT the whole environment is restarted.

So, What does exactly "Allow/Disallow launching" does after setting the metadata::trusted? How does it refresh the metadata in the .desktop itself without refreshing the whole Desktop?

like image 317
Lango Avatar asked Feb 05 '20 11:02

Lango


2 Answers

Your question is exactly the same as what I'm looking for.

On Ubuntu 18.04 (GNOME 3.28):

dbus-launch gio set file.desktop "metadata::trusted" yes

and (although this is not quite what you need)

killall nautilus-desktop && nautilus-desktop & disown

Ubuntu 20.04 (GNOME 3.36):

dbus-launch gio set file.desktop "metadata::trusted" true

but no nautilus-desktop...

dbus-send --type=method_call --print-reply --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'global.reexec_self()'

or something like systemd*...

Look at this code:

https://gitlab.gnome.org/GNOME/nautilus/commit/1630f5348

and here search "trusted":

https://download.gnome.org/core/3.36/3.36.2/sources/

nautilus-3.36.2/src/nautilus-file-operations.c

nautilus-3.36.2/src/nautilus-mime-actions.c

like image 82
xpi-io Avatar answered Oct 16 '22 17:10

xpi-io


It may turns out to be simpler. From desktop-file-utils.

man desktop-file-install

For example:

desktop-file-install --mode=0755 --dir=$HOME/Desktop /path/to/source/file.desktop
like image 39
xpi-io Avatar answered Oct 16 '22 18:10

xpi-io