Ubuntu – How to change the folder icon in Nautilus with a command

appearanceiconsnautilussettingsthemes

I know how to change an icon this way. Also that doesn't work for folders inside Nautilus, but for application launchers.


What I'm looking for is an equivalent to changing the icon for an application in the launcher, i. e. the Home folder, via

gedit ~/.local/share/applications/nautilus-home.desktop

change home icon

That way you can set an icon type, which is helpful when you later want to change the icon set resp. theme or when you want the best resolution for each size of the icon.

So, I know how I can do this for applications in the launcher – but how can I realize this for icon folders in Nautilus? (In which file these settings are stored and editable with i. e. Gedit?)


For example, I try to change the folder icon for ~/.wine/drive_c. I want to use this Faenza icon (I use Faenza-theme, the icon is called folder-wine.png):

wine icon

I want it to appear in best resolution: smaller as bookmark in Nautilus' sidebar, bigger as folder icon when I search Unity's dash. Using the scalable svg is not a solution, because it looks slightly different from the equivalent png.

Best Answer

If you want to change the special folder icons (xdg user directories), you'll have to change them by making a custom theme. They are set to a specific name which is provided by the theme, and based on which folders are set as your Music, Documents, Videos, etc… folders.

To set a custom icon name to use from the theme, for the ~/.wine/drive_c folder for example, you can run the following in a terminal:

gvfs-set-attribute ~/.wine/drive_c metadata::custom-icon-name folder-wine

This should make Nautilus use the folder-wine icon. However, this icon will not be used in GTK+ file selectors or other applications. To unset the custom icon name, you can run the following in a terminal:

gvfs-set-attribute -t unset ~/.wine/drive_c metadata::custom-icon-name folder-wine

Note, that if you've previously set a custom icon on the file, within Nautilus directly, you'll have to unset that icon. You can do this by opening the properties dialog for that file in Nautilus, clicking on the button with the icon on it, and choosing "Revert" in the file chooser dialog which opens up.

Related Question