如何为 Linux:KDE、Gnome 等设置应用程序的桌面图标?

发布于 2024-07-06 02:21:35 字数 243 浏览 9 评论 0原文

我有一个可以在 Windows、Linux 和 Macintosh 上运行的跨平台程序。 我的 Windows 版本有一个图标,但我不知道如何为我的 Linux 版本制作一个图标。 KDE、Gnome 等有标准格式吗?还是我必须为每一种格式做一些特殊的事情?

我的应用程序是用 C++ 编写的,并作为源代码分发,因此最终用户将使用 gcc 对其进行编译。

如果我可以将图标直接嵌入到我的 exe 二进制文件中,那就最好了。

I have a cross platform program that runs on Windows, Linux and Macintosh. My windows version has an Icon but I don't know how to make have one for my Linux build.
Is there a standard format for KDE, Gnome etc. or will I have to do something special for each one?

My app is in c++ and distributed as source so the end user will compile it with gcc.

If I can have the icon embedded directly inside my exe binary that would be the best.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

沫雨熙 2024-07-13 02:21:35

对于 Gnome 和 Kde,您可能希望在应用程序中包含一个桌面文件,该文件定义了应用程序的启动方式。 该规范可以在此处找到。 如果您的应用程序中包含安装程序,您可能希望让它生成此桌面文件并将其放在正确的位置以制作菜单条目等

For Gnome and Kde, you would probably want to include a desktop file with your app that defines how it will be launched. The specification can be found here. If you have an installer included with your app, you would probably want to have it generate this desktop file and put it in the right places to make menu entries and whatnot

洛阳烟雨空心柳 2024-07-13 02:21:35

如果您使用预烘焙的 F/OSS 构建系统之一,例如 KDE 的 CMake 支持,那么一旦您拥有 .desktop 文件,这真的相当容易:

install( FILES myapp.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
kde4_add_app_icon(myapp_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/hi*-app-myappname.png")

如果您自己推出,请考虑使用 xdg-utils,其中包括一些方便的小脚本,例如 xdg-desktop-menu(安装桌面菜单项)和 xdg-desktop-icon(将图标安装到桌面)。

.desktop 标准已经在第一条评论中指出,尽管您也可以只获取系统上已安装的标准并从那里修改它。 至于图标,尽管 PNG 往往仍能提供最佳效果,但普遍支持 PNG 和 SVG。

If you are using one of the pre-baked F/OSS build systems, such as KDE's CMake support, it's really rather easy once you have a .desktop file:

install( FILES myapp.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
kde4_add_app_icon(myapp_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/hi*-app-myappname.png")

If you are rolling your own, consider using xdg-utils, which includes handy little scripts like xdg-desktop-menu (installs desktop menu items) and xdg-desktop-icon (installs icons to the desktop) for such things.

The .desktop standard was already pointed out in the first comment, though you can also just grab one that is already installed on your system and modify it from there. As for icons, PNGs and SVGs are geerally supported though PNGs tend to give the best results still.

栖迟 2024-07-13 02:21:35

KDE 社区及其 KDE 4 系列开始使用 CMake 作为构建系统。 他们开发了一个 CMake 宏,它知道如何为您的应用程序设置图标,无论平台如何(Windows(嵌入在 exe 中)、mac(.app 捆绑包)、linux(.desktop 文件)等)

也许您可以使用它。

KDE community with it's KDE 4 series started to use CMake as a build system. They developed a CMake macro that knows how to set an icon for your application regardles of the platform (windows (embedded in exe), mac (.app bundles), linux (.desktop files) etc.)

Maybe you can use it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文