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)
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.
I was recently trying to do something similar with creating desktop shortcuts on various Linux platforms and found this post.
For more information, see the Desktop Entry Specification from freedesktop.org which describes the standard for desktop and directory shortcuts on KDE and GNOME desktops.
There is no standard way to do this across GNOME, KDE, and CDE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With