Where does Gnome/Nautilus store directory icons

On some key folders in nautilus I've changed the folder icons. It looks nice, and aids my productivity because I can easily find important folders in a mass of others.

But then I move to another machine and all the folders are plain again.

So the question is where is this stored, and is there a way to have it persist between users/systems.


Solution 1:

The meta-data is stored using the meta-data storage system of GIO/GVFS. You can see what attributes are stored on a file by running gvfs-info /path/to/file in a terminal. To have the same folders with the same icons on a different machine, you'll generally have to manually set the icons again. Also note that the custom icons won't show up when browsing the folders remotely via sftp or some similar means.

Solution 2:

Take a look in /usr/share/icons.

Gnome stores its icons there.

Solution 3:

gio info

Since gvfs-info is outdated, use gio info instead. To get information about a dir/file simple use

gio info /path/to/director/or/file

After invoking this command you will get an output like

...
metadata::custom-icon: file:///home/.../.../myicon.png
...

If you would like the exact full-path name of your icon in a script use something like:

gio info /path/to/director/or/file | awk '/custom-icon/ {print $2}' | cut -c8-

Usage: gio info [OPTION…] LOCATION…

Show information about locations.

Options:
-w, --query-writable : List writable attributes
-f, --filesystem : Get file system info
-a, --attributes=ATTRIBUTES: The attributes to get
-n, --nofollow-symlinks: Don’t follow symbolic links

gio info is similar to the traditional ls utility, but using GIO locations instead of local files: for example, you can use something like smb://server/resource/file.txt as location. File attributes can be specified with their GIO name, e.g. standard::icon, or just by namespace, e.g. unix, or by “*”, which matches all attributes

How to set an icon from command line can be found here.

A complete set of the gio commands can be found on the gnome developer page.

Solution 4:

No, wait, you got the wrong answer. Icon settings can be copied over from machine to machine, of course they can, there's nothing you can't do on Linux.

Icon settings are stored in the folder:

~/.local/share/gvfs-metadata

If you'd like you can try it on a virtual machine, what you have to do is:

  • Copy all of your files from your old system (system backup) to new system (all of ~/ directory)
  • Make sure you have copied over the gvfs-metadata folder, as well as the folder that includes your custom icons (I would assume it is ~/.icons). If you have copied all of ~/, this would be automatically done.
  • Delete the gvfs-metadata you have just copied, and copy it again from system backup.
  • Do: $: killall nautilus

And there you go, you have them back.

I have just moved to a new computer and it worked for me. I tested it also on a VM.

Note: if you do gvfs-info folder_name you won't see the custom icon path unless you have copied over the gvfs-metadata folder. As this instruction checks that folder for information.