views:

310

answers:

2

In Linux, can one set a custom icon for a folder/directory as it appears in a desktop/file manager?

For example for Windows Explorer one can set a custom icon in the folder's desktop.ini file?

If so, is there a common mechanism or API function to do this (that is perhaps common among distros/desktops/file managers)?

I would like to do this from a standalone console mode program C++ or perhaps using the desktop API for KDE, gnome etc.. (also Unix CDE and OSX)

+1  A: 

There is no standard way to do this across GNOME, KDE, and CDE.

anthony
+4  A: 

If you are using the KDE desktop, then simply create a .directory file inside the directory.

E.g. I have a custom icon for my directory named "dev.sparc". I created this using the KDE desktop. All it does is create a file which I can view.

$ cat dev.sparc/.directory
[Desktop Entry]
Icon=applications-engineering

Et voila. That's all there is to it. If you or your users are using Gnome, this will be similar but probably subtly different. Just create an empty directory, use Gnome to set an icon, then $ ls -al in the directory to see what file it created.

the.jxc