Linux 桌面快捷方式和安装图标

发布于 2024-07-04 17:26:10 字数 107 浏览 4 评论 0原文

我需要在 .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 技术交流群。

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

发布评论

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

评论(3

抚你发端 2024-07-11 17:26:10

要为应用程序创建桌面图标,请按照以下两个步骤操作。

  1. 在编辑器中创建一个新文件。

    gedit ~/.local/share/applications/NameYouWantForApplication.desktop 
      
  2. 将此部分放入文件中并保存。

    [桌面入口] 
      类型=应用 
      编码=UTF-8 
      名称=JeremysPentaho 
      评论=你想要什么评论 
      Exec=/home/[电子邮件受保护]/Source/Pentaho/data-集成/spoon.sh 
      Icon=/home/[电子邮件受保护]/Source/Pentaho/data-集成/NameOfmyIconFile.jpg 
      终端=假 
      

To create a desktop icon to an application follow the two steps below.

  1. In an Editor create a new file.

    gedit ~/.local/share/applications/NameYouWantForApplication.desktop
    
  2. Place this section within the file and save it.

    [Desktop Entry]
    Type=Application
    Encoding=UTF-8
    Name=JeremysPentaho
    Comment=Whatever Comment You want
    Exec=/home/[email protected]/Source/Pentaho/data-integration/spoon.sh
    Icon=/home/[email protected]/Source/Pentaho/data-integration/NameOfmyIconFile.jpg
    Terminal=false
    
挥剑断情 2024-07-11 17:26:10

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).

野却迷人 2024-07-11 17:26:10

您在 Linux 下使用 .desktop 文件作为图标。 图标放置的位置取决于您使用的发行版和桌面环境。 由于我目前在 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;

Fedora 9 Gnome 下的 .desktop 文件应位于 /usr/share/applications/ 中,您可以在 .desktop 上运行locate 来确定应将其放入发行版中的位置。 Gnome 通常会查看 KDE 图标目录,看看那里是否还有其他图标......

编码、名称和执行应该不言而喻。

  • 通用名称 == 应用程序简要说明。
  • Icon == 图标显示的图像
  • 终端 == 这是一个终端应用程序,我应该将其作为一个终端应用程序启动吗?
  • Type == 这是程序的类型,可用于将图标放入菜单中。
  • 类别== 此信息主要用于在指定菜单中放置图标(如果不存在指定此类的 XML 文件)。 每个人对菜单设置的处理方式都略有不同。

您可以设置更多属性,但它们并不是绝对必要的。

使用的图像文件位于 /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:

[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;

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....

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.

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).

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