Is it possible to modify GNOME desktop file metadata from non-GUI session using gio?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Is it possible to modify GNOME desktop file metadata from non-GUI session using gio?



Running CentOS 7 with GNOME 3.22.2, and I am trying to write an Ansible playbook to copy icons from /usr/share/applications to a pre-defined user's desktop and then grant trusted permission (Using gio set "metadata::trusted" yes).


gio set "metadata::trusted" yes



When I try to see the writeable attributes of the desktop icon from a terminal session using gio info -w /home/demo/Desktop/google-chrome.desktop, I get this result:


gio info -w /home/demo/Desktop/google-chrome.desktop


Settable attributes:
standard::symlink-target (bytestring)
time::access (uint64, Keep with file when moved)
time::access-usec (uint32, Keep with file when moved)
time::modified (uint64, Copy with file, Keep with file when moved)
time::modified-usec (uint32, Copy with file, Keep with file when moved)
unix::gid (uint32, Keep with file when moved)
unix::mode (uint32, Copy with file, Keep with file when moved)
unix::uid (uint32, Keep with file when moved)
Writable attribute namespaces:
xattr (string, Copy with file, Keep with file when moved)
xattr-sys (string, Keep with file when moved)



So when I try the to run the above gio set command, it fails with gio: Setting attribute metadata::trusted not supported because metadata can't be written. However, if I log into a GUI session and run the same command from a terminal, then I see that metadata is now a writable attribute:


gio set


gio: Setting attribute metadata::trusted not supported


Settable attributes:
standard::symlink-target (bytestring)
time::access (uint64, Keep with file when moved)
time::access-usec (uint32, Keep with file when moved)
time::modified (uint64, Copy with file, Keep with file when moved)
time::modified-usec (uint32, Copy with file, Keep with file when moved)
unix::gid (uint32, Keep with file when moved)
unix::mode (uint32, Copy with file, Keep with file when moved)
unix::uid (uint32, Keep with file when moved)
Writable attribute namespaces:
metadata (string, Copy with file, Keep with file when moved)
xattr (string, Copy with file, Keep with file when moved)
xattr-sys (string, Keep with file when moved)



This means the gio set command works in a GNOME GUI session, but not in a terminal session. I'm trying to figure out if there way to allow the terminal session to be able to modify this (so that my playbook can make this modification). I'm not against having to use a different scripting language to do that if that's what it takes.


gio set



For information, the current Ansible playbook section looks like so:


- name: Make Chrome Launcher Trusted
shell: gio set /home/demo/Desktop/google-chrome.desktop "metadata::trusted" yes





would be interesting to add the relevant part of the playbook, thanks
– Baptiste Mille-Mathias
Aug 8 at 19:21





- name: Make Chrome Launcher Trusted shell: gio set /home/demo/Desktop/google-chrome.desktop "metadata::trusted" yes
– jhrabi
Aug 8 at 19:49



- name: Make Chrome Launcher Trusted shell: gio set /home/demo/Desktop/google-chrome.desktop "metadata::trusted" yes





From an ansible perspective, I added a script in the /home/demo/.config/autostart directory that runs the gio set command on GNOME startup. So there's at least a workaround.
– jhrabi
Aug 14 at 16:36









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard