Linux 桌面快捷方式和安装图标
我需要在 .spec
文件中添加哪些内容才能创建桌面快捷方式,并在安装 .rpm
期间为该快捷方式分配图标? 如果需要脚本,一个示例将非常有帮助。
What do I need to add to my .spec
file to create the desktop shortcut and assign an icon to the shortcut during install of my .rpm
? If a script is required, an example would be very helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要为应用程序创建桌面图标,请按照以下两个步骤操作。
在编辑器中创建一个新文件。
将此部分放入文件中并保存。
To create a desktop icon to an application follow the two steps below.
In an Editor create a new file.
Place this section within the file and save it.
akdom 给出了相当好的答案,但没有公正地对待其相关性。
许多常见桌面(包括相关的 Gnome、KDE 和 XFCE)都实现 freedesktop.org 制定的规范。 其中,桌面条目规范描述了以下文件的格式:定义桌面图标,以及描述桌面环境应放置的位置的桌面基本目录规范寻找这些文件。
您的 RPM 需要包含一个 .desktop 文件,如 桌面条目规范,并将其安装在桌面基本目录规范,或在特定于发行版的位置(我想在该位置的规范文件中将使用别名)。
akdom has given a fairly good answer, but doesn't do its relevance justice.
Many common desktops, including Gnome, KDE and XFCE where relevant, implement the specifications laid out by freedesktop.org. Among these, is the Desktop Entry Specification which describes the format of files that define desktop icons, and Desktop Base Directory Specification that describes the locations that desktop environments should look to find these files.
Your RPM needs to include a .desktop file, as specified by the Desktop Entry Specification, and install it in the correct location as specified either by the Desktop Base Directory Specification, or in a distribution specific location (I imagine there will be aliases to use in the spec file for this location).
您在 Linux 下使用 .desktop 文件作为图标。 图标放置的位置取决于您使用的发行版和桌面环境。 由于我目前在 Fedora 9 上运行 Gnome,因此我将用这些术语来回答这个问题。
foo.desktop 文件的示例如下:
Fedora 9 Gnome 下的 .desktop 文件应位于 /usr/share/applications/ 中,您可以在 .desktop 上运行locate 来确定应将其放入发行版中的位置。 Gnome 通常会查看 KDE 图标目录,看看那里是否还有其他图标......
您可以设置更多属性,但它们并不是绝对必要的。
使用的图像文件位于 /usr/share/icons/ 目录内部的某个位置。 你可以通过解析它来发现这些东西如何工作的所有奇迹,但基础是你选择图标类型的目录(在我的例子中是 gnome)并将图像放置在适当的目录中(有一个可扩展的目录用于.svg 图像,以及特定尺寸,例如 48x48 的光栅图像,在 Gnome 下,所有图像通常都是 .png)。
You use a .desktop file for icons under linux. Where to put the icon depends on what distribution and what desktop environment you are using. Since I'm currently running Gnome on Fedora 9, I will answer it in those terms.
An example foo.desktop file would be:
The .desktop file should under Fedora 9 Gnome be located in /usr/share/applications/ , you can run a locate on .desktop to figure out where you should put in on your distro. Gnome will generally look in the KDE icon directory to see if there are other icons there also....
There are more attributes you can set, but they aren't strictly necessary.
The image file used sits somewhere in the bowels of the /usr/share/icons/ directory. You can parse through that to find all the wonders of how such things work, but the basics are that you pick the directory for the icon type (in my case gnome) and place the image within the appropriate directory (there is a scalable directory for .svg images, and specific sizes such as 48x48 for raster images. Under Gnome all images are generally .png).