在Linux中以编程方式设置自定义文件夹/目录图标 [英] Programmatically set custom folder/directory icon in Linux

查看:285
本文介绍了在Linux中以编程方式设置自定义文件夹/目录图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux中,是否可以为桌面/文件管理器中显示的文件夹/目录设置自定义图标?

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

例如,对于Windows资源管理器,可以在文件夹的desktop.ini文件中设置自定义图标吗?

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

如果是,是否有通用的机制或API函数来执行此操作 (这在发行版/桌面/文件管理器中可能很常见)?

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

我想通过独立的控制台模式程序C ++进行此操作 或将桌面API用于KDE,gnome等. (以及Unix CDE和OSX)

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)

推荐答案

如果您使用的是KDE桌面,则只需在目录内部创建一个.directory文件.

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

例如我的目录中有一个自定义图标,名为"dev.sparc".我是使用KDE桌面创建的.它所做的只是创建一个我可以查看的文件.

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

瞧.这里的所有都是它的.如果您或您的用户使用的是Gnome,这将是相似的,但可能会有所不同.只需创建一个空目录,使用Gnome设置图标,然后在目录中单击$ ls -al即可查看创建的文件.

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.

这篇关于在Linux中以编程方式设置自定义文件夹/目录图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆