Linux desktop shortcut and icon from install

前端 未结 3 942
春和景丽
春和景丽 2021-02-06 11:01

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 req

相关标签:
3条回答
  • 2021-02-06 11:27

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

    0 讨论(0)
  • 2021-02-06 11:37

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

    0 讨论(0)
  • 2021-02-06 11:43

    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/yourname@yourdomain.com/Source/Pentaho/data-integration/spoon.sh
      Icon=/home/yourname@yourdomain.com/Source/Pentaho/data-integration/NameOfmyIconFile.jpg
      Terminal=false
      
    0 讨论(0)
提交回复
热议问题