tags:

views:

1951

answers:

2

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.

+1  A: 

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

akdom
Hi askdom, please tell me what I have to mention in my .spec file to get desktop file icon in order to create my rpm
Deepak
+1  A: 

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

SpoonMeiser