Linux桌面快捷方式和安装图标
安装.rpm时,我需要添加什么到.spec文件中以创建桌面快捷方式并为该快捷方式分配一个图标?如果需要脚本,那么使用示例将非常有帮助。
解决方案
回答
我们将.desktop文件用于Linux下的图标。放置图标的位置取决于我们所使用的发行版和桌面环境。由于我当前正在Fedora 9上运行Gnome,因此我将以这些方式回答。
foo.desktop文件的示例为:
[Desktop Entry] Encoding=UTF-8 GenericName=Generic Piece Of Software Name=FooBar Exec=/usr/bin/foo.sh Icon=foo.png Terminal=false Type=Application Categories=Qt;Gnome;Applications;
.desktop文件应该位于Fedora 9 Gnome下,位于/ usr / share / applications /中,我们可以在.desktop上运行一次定位,以确定应该在发行版中放置的位置。 Gnome通常会在KDE图标目录中查找是否还有其他图标。
Encoding, Name and Exec should speak for themselves. Generic name == Brief Description of application. Icon == The image to display for the icon Terminal == Is this a terminal application, should I start it as one? Type == Type of program this is, can be used in placing the icon in a menu. Categories == This information is what is mainly used to place the icon in a given menu if an XML file to specify such is not present. The setup for menus is handled a little differently by everyone.
我们可以设置更多的属性,但并不是必须的。
所使用的图像文件位于/ usr / share / icons /目录中的某个位置。我们可以解析所有内容,以发现这些事情是如何工作的,但基本原理是我们选择图标类型的目录(在我的情况下是gnome),然后将图像放置在适当的目录中(对于.svg图像,以及用于光栅图像的特定尺寸(例如48x48. 在Gnome下,所有图像通常都是.png)。
回答
akdom给出了一个很好的答案,但没有做到相关性正义。
许多常见的桌面(包括相关的Gnome,KDE和XFCE)都实现了freedesktop.org制定的规范。其中,Desktop Entry Specification(桌面条目规范)描述了定义桌面图标的文件格式; Desktop Base Directory Specification(桌面基本目录规范),描述了桌面环境查找这些文件所应查找的位置。
RPM需要包括一个由Desktop Entry Specification指定的.desktop文件,并将其安装在Desktop Base Directory Specification指定的正确位置,或者安装在特定于发行版的位置(我想会有别名可以使用在此位置的规范文件中)。