File metadata and gio

I’m trying to work with the metadata::custom-icon file attribute and I’m struggling to find some information.

The first issue I’m having is that gio set Octopus4 "metadata::custom-cion" "file::///home/afranke/Musique/The Algorithm/Octopus4/cover.jpg" tells me setting this attribute is not supported. This used to work. I tried to find in the glib repository a reason for this not to work anymore, but came out of it empty-handed. I also tried various gio invocations to read the attribute on directories I know have it, but no luck either (which at least is consistent with gio not supporting the attribute).

Being able to do this from gio would have been convenient for testing purpose, but regardless of this, I’d like to understand where that specific attribute is stored, and how strongly it is tied to glib. In other words, could I programmatically access the attribute from any language without requiring glib? Not that I necessarily need to avoid glib, this is just for my understanding of what’s going on. I did try to read the glib and nautilus source for this as well, but didn’t manage to get all the way to the answer.

This is stored in the GVfs metadata database that extends Glib/GIO, see Projects/gvfs/doc - GNOME Wiki! (you can use the org.gtk.vfs.Metadata D-Bus API for debugging). So gvfs package is not installed, or dbus session is not running, or you just don’t have access to it, or you don’t have access to gvfs sockets… what are the exact steps to reproduce this issue (what is your system, version, what terminal application is used etc.)? It reminds me: gio to samba fails, smbclient and cifs work (#580) · Issues · GNOME / gvfs · GitLab.

1 Like

Thank you, this is exactly the information I was after. That is the sort of documentation that is difficult to look up as the terms aren’t really specific enough and I didn’t even know where I was supposed to look. I did try though, but even if it had been there, kind of a find the haystack before you can start searching for the needle situation.
I was indeed trying from a flatpaked WezTerm. I now tried from GNOME Terminal (Fedora package) and the gio set invocation worked as expected. I am still unsure how to query the specific field using the gio command. I tried gio info --query-writable . which gives me a line with metadata (string, Copier avec le fichier, Conserver avec le fichier lors du déplacement) but no more details about metadata. I have also tried gio info -a 'metadata::custom-icon' . which gives me a URI, local path and Unix mount point for . but nothing more. Not a big deal, I have enough to keep going now, but it would be a nice bonus to clarify this last bit.

I am not sure what exactly needs to be clarified. The gio info [file] without the -a parameter prints all available attributes (it is equivalent to -a '*') for the concrete file path, or URI. You can use e.g. metadata::* to print all metadata attributes (if there are any). With 'metadata::custom-icon' cmd it prints only the metadata::custom-icon attribute (if it is set). So in your case, it looks like the metadata::custom-icon attribute is not set for the current directory (i.e. .) if you don’t see anything in the attributes: section. The --query-writable shows just metadata as the concrete attributes are not “standardized” and you resp. your application can set whatever metadata attribute…

$ gio set . "metadata::foo" bar
$ gio info -a "metadata::foo" .
  metadata::foo: bar
1 Like

I must have mixed up my paths in my previous attemps. Everything now works as expected. Sorry about the noise and thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.