Fedora RPMs - Desktop Entry

Contents

Overview

According to the Packaging Guidelines a GUI application is defined as any application which draws an X window and runs from within that window. Therefore, the NetBeans is the GUI application even from viewpoint of the fedoraproject.org. Hence, a properly installed .desktop file for the NetBeans application should be also provided.

This article explains a solution for the .desktop file that has been used in the native package for Fedora 10.

The solution described here could be used in the native packages for other Linux systems that use KDE and/or GNOME desktop environments and meet with Desktop Entry Specification.

Desktop Template

The solution is based on a template of the desktop file. A simplest version of the desktop template is used in the current release of the native packages for Fedora 10. The desktop template is provided as a separate source (Source2) defined in the RPM spec file - netbeans-ide.desktop-template:

[DesktopEntry]
Type=Application
Version=1.0
Name=NetBeans IDE <nb_ver>
GenericName=Integrated Development Environment (IDE)
Comment=The only IDE you need!
Icon=<nb_icon>
TryExec=<nb_launcher>
Exec=<nb_launcher>
Terminal=false
Categories=Development;Java;IDE;
StartupNotify=true

The template contains a set of variables. Variable is a part of the template intended to be substituted by real text. To recognize variables in the text of template their identifiers are enclosed within the angle brackets - <...>.

{{{1}}}

Desktop Template Variables

Current version of the template contains the following variables:

Variable Description
<nb_ver> Version of the NetBeans, e.g. "6.1", "6.5", ...
<nb_icon> Path to the icon file for the NetBeans IDE (application)
<nb_launcher> Path to the launcher of the NetBeans IDE (application)


Building of the Desktop File

The simplest script is used to build final desktop file. Commands of this script are inserted as part of the %build section of the RPM spec:

# Build desktop file
%{__cp} -p %{nb_desktop_template} %{nb_desktop}
sed --in-place "s|<nb_ver>|%{nb_ver}|g" %{nb_desktop}
sed --in-place "s|<nb_icon>|%{nb_icon}|g" %{nb_desktop}
sed --in-place "s|<nb_launcher>|%{nb_launcher}|g" %{nb_desktop}

where used macro definitions are:

%define nb_              netbeans
%define nb_ver           6.1
%define nb_home          %{_datadir}/%{nb_}
%define nb_dir           %{nb_home}/%{nb_ver}

%define nb_nb           nb%{nb_ver}
%define nb_nb_dir       %{nb_dir}/%{nb_nb}
%define nb_bin_dir      %{nb_dir}/bin

%define nb_icon         %{nb_nb_dir}/netbeans.png
%define nb_launcher     %{nb_bin_dir}/netbeans
%define nb_desktop      %{name}-ide-%{version}.desktop

%define nb_desktop_template %{SOURCE2}


Installation of the Desktop File

Installation of the desktop file is provided also by the simplest script. Commands of this script are inserted as part of the %install section of the RPM spec:

# Install desktop file
desktop-file-validate  %{nb_desktop}
install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/applications/%{nb_org}
desktop-file-install --vendor="" \
    --dir=$RPM_BUILD_ROOT%{_datadir}/applications/%{nb_org} \
    %{nb_desktop}

where:

%define nb_org           %{nb_}.org

Ways to Improvement

I18N

...
Name=NetBeans IDE <nb_ver>
Name[Ru]=NetBeans IDE <nb_ver> Интегрированная Среда Разработки
...
GenericName=Integrated Development Environment (IDE)
GenericName[Ru]=Интегрированная Среда Разработки (IDE)
...
Comment=The only IDE you need!
Comment[Ru]=Интегрированная Среда Разработки необходимая Вам!
...

Using other agreements

Icon Key

If location of the icon file for the IDE will meet with conditions described in the Icon Theme Specification then we can avoid using the <nb_icon> variable in the template.

MimeType Key

A list of supported MIME Types by the NetBeans can be added. See Registering MIME Types.

Issue: the list shuld be changed if additional plugins are installed (or deinstalled !), including via the NetBeans Update Center. Therefore, it should be possible to modify a value of the MimeType Key from inside NetBeans, i.e. the Desktop File API should be provided by the NetBeans platform.

TryExec and Exec Keys

We can avoid using the <nb_launcher> variable in the template if the simple name of the launcher (netbeans) will be used instead of the absolute path to it. In this case, the launcher should be placed in a directory listed by default in the system variable PATH.

Resources

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo