Where does Gnome/Nautilus store directory icons

38,803

Solution 1

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 2

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 3

Take a look in /usr/share/icons.

Gnome stores its icons there.

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.

Share:
38,803

Related videos on Youtube

artfulrobot
Author by

artfulrobot

Stitching together websites, databases and open source cunning to help you change the world.

Updated on September 18, 2022

Comments

  • artfulrobot
    artfulrobot over 1 year

    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.

  • Eliah Kagan
    Eliah Kagan over 11 years
    Those are icons that ship with the system or that are otherwise provided by Ubuntu packages. Data added by the user are not stored there. See the FHS for details on what the /usr/share directory contains.
  • Alexis Wilke
    Alexis Wilke over 10 years
    @EliahKagan, In the question the user did not say "my own icons".
  • artfulrobot
    artfulrobot almost 9 years
    That's where icons are, but not where the association with specific directories are. You may choose a file from the standard icons to represent one folder, but the issue is that if you then view that folder from another computer or another user on the same computer you will not see that icon.
  • artfulrobot
    artfulrobot about 4 years
    Thanks for the update!
  • dobey
    dobey about 4 years
    Any reason to not update the existing answer? While gio info may be the way to do it on the latest release of Ubuntu, gvfs-info is still the way it works on some older versions which are still supported. So outdated isn't quite entirely true in respect to giving answers here.
  • abu_bua
    abu_bua about 4 years
    According to the man page of gvfs-info: "gvfs-info has been deprecated and it is redirected to gio info." It's true that gvfs still works and is available, even on Ubuntu 20.04.
  • dobey
    dobey about 4 years
    Yes. On 20.04. However, 16.04 and 18.04 are still supported. And 14.04 and possibly 12.04 for those paying Canonical for extended support. Thus, the instructions to use gvfs-info are still very valid, especially since this question was asked in 2012 anyway. gio info does not necessarily even exist on those older versions of Ubuntu.