What's the rela开发者_如何转开发tionship between .desktop files in the /usr/share/applications, the xdg-desktop-menu command and update-desktop-database command?
I'm trying to make a RPM that creates a desktop icon for my app. In the RPM, I install the vendor-appname.desktop file into /usr/share/applications. Then I have the following post-install script:
if [ -x "`which xdg-desktop-menu 2>/dev/null`" ]; then
xdg-desktop-menu install $RPM_BUILD_ROOT/usr/share/applications/vendor-myapp.desktop
fi
if [ -x "`which update-desktop-database 2>/dev/null`" ]; then
update-desktop-database &> /dev/null || :
fi
And the icon is not created. The icon IS created if I run the
xdg-desktop-menu install $RPM_BUILD_ROOT/usr/share/applications/vendor-myapp.desktop
command manually later on, as a non-root. If I do so as a root (which is, supposedly, how the RPM does it), the icon is not created. Also, I have a very strong suspicion that the update-desktop-database
under if[] bit is not executed. It is executed when I manually run the whole if[]
statement.
Fedora Linux with Gnome.
On Fedora, be sure of:
BuildRequires: desktop-file-utils Requires(post): desktop-file-utils Requires(postun): desktop-file-utils
Then (%{SOURCE1} is your desktop file):
%install [...] desktop-file-install \ --dir=${RPM_BUILD_ROOT}%{_datadir}/applications \ %{SOURCE1} [...] %post update-desktop-database &> /dev/null || : %postun update-desktop-database &> /dev/null || :
If you install your own icon, you also need to update the icon cache, adding in the relative specfile sections:
%post touch --no-create %{_datadir}/icons/hicolor &>/dev/null || : %postun if [ $1 -eq 0 ] ; then touch --no-create %{_datadir}/icons/hicolor &>/dev/null gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : fi %posttrans gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
Refs:
http://fedoraproject.org/wiki/PackagingGuidelines#Desktop_files
http://freedesktop.org/wiki/Software/desktop-file-utils
http://fedoraproject.org/wiki/Packaging/ScriptletSnippets#Icon_Cache
精彩评论