Linux desktop shortcut and icon from install

前端 未结 3 941
春和景丽
春和景丽 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: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).

提交回复
热议问题