Teuniz
July 14, 2011, 2:33pm
#1
Hello,
I created the folowing files:
myapp.desktop
[Desktop Entry]
X-SuSE-translate=true
Encoding=UTF-8
Type=Application
Name=myapp
Comment=Some app...
Icon=myapp.png
Exec=myapp
Terminal=false
Categories=Education;Science;DataVisualization;
MimeType=application/x-edf;application/x-bdf
InitialPreference=9
myapp.xml
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-edf">
<comment>European Data Format 16-bits</comment>
<magic priority="50">
<match type="string" offset="0" value="0 "/>
</magic>
<generic-icon name="edf"/>
<glob pattern="*.edf"/>
</mime-type>
<mime-type type="application/x-bdf">
<comment>European Data Format 24-bits</comment>
<magic priority="50">
<match type="string" offset="1" value="BIOSEMI"/>
</magic>
<generic-icon name="edf"/>
<glob pattern="*.bdf"/>
</mime-type>
</mime-info>
and the installerscript install_myapp.sh
#!/bin/sh
#
cp myapp /usr/bin/
#
cp images/edf.png /usr/share/icons/
cp images/edf.png /usr/share/pixmaps/
#
cp myapp.desktop /usr/share/applications/
#
cp myapp.xml /usr/share/mime/packages/
#
#
update-mime-database /usr/share/mime/
#
The scripts runs ok, the fileassociations work correctly, myapp will be started when clicking on the right datafile.
The only thing that doesn’t want to work, is to create a startmenu entry for myapp.
Please can anybody help me and tell me what is missing here?
Regards,
Teuniz
Teuniz
July 14, 2011, 3:46pm
#3
Thanks for helping me.
On my machine (openSuse 11.3 with KDE4) $XDG_DATA_DIRS is /usr/share, so apart from the menu file, my script works correctly.
According to Desktop Menu Specification , myapp.desktop has the right categories incorporated and it should be added to the menu automatically.
Indeed, when I run this script on Ubuntu with Gnome, the menu entry is created.
The list of Main Categories consist of those categories that every conforming desktop environment MUST support. By including one of these categories in an application’s desktop entry file the application will be ensured that it will show up in a section of the application menu dedicated to this category.
Does this mean that openSuse doesn’t confirm to the desktop specification?
Other software/rpm’s do not install a menu entry as well. For example:
Skype:
skype - Skype is free Internet telephony that just works
/etc/dbus-1/system.d/skype.conf
/usr/bin/skype
/usr/share/applications/skype.desktop
/usr/share/doc/skype-2.1.0.81
/usr/share/doc/skype-2.1.0.81/LICENSE
/usr/share/doc/skype-2.1.0.81/README
/usr/share/icons/skype.png
/usr/share/pixmaps/skype.png
Jubler:
/usr/bin/jubler
/usr/lib/Jubler
/usr/lib/Jubler/libffdecode.so
/usr/share/applications/jubler.desktop
/usr/share/doc/packages/Jubler
/usr/share/doc/packages/Jubler/LICENCE
/usr/share/doc/packages/Jubler/README
/usr/share/doc/packages/Jubler/help
/usr/share/doc/packages/Jubler/help/jubler-faq.html
/usr/share/doc/packages/Jubler/help/question.png
/usr/share/icons/hicolor/128x128/mimetypes/application-x-ass.png
/usr/share/icons/hicolor/128x128/mimetypes/application-x-srt.png
/usr/share/icons/hicolor/128x128/mimetypes/application-x-ssa.png
/usr/share/icons/hicolor/128x128/mimetypes/application-x-sub.png
/usr/share/icons/hicolor/128x128/mimetypes/subtitle.png
/usr/share/icons/hicolor/48x48/apps/jubler.png
/usr/share/icons/hicolor/48x48/mimetypes/application-x-ass.png
/usr/share/icons/hicolor/48x48/mimetypes/application-x-srt.png
/usr/share/icons/hicolor/48x48/mimetypes/application-x-ssa.png
/usr/share/icons/hicolor/48x48/mimetypes/application-x-sub.png
/usr/share/icons/hicolor/48x48/mimetypes/subtitle.png
/usr/share/java/Jubler-4.1.3.jar
/usr/share/java/Jubler.jar
/usr/share/man/man1/jubler.1.gz
/usr/share/mime/packages/jubler.xml
/usr/share/pixmaps/jubler.png
/usr/share/pixmaps/jubler.xpm
Audacious
/usr/bin/audacious
/usr/bin/audtool
/usr/lib/audacious
/usr/lib/audacious/Container
/usr/lib/audacious/Effect
/usr/lib/audacious/General
/usr/lib/audacious/Input
/usr/lib/audacious/Output
/usr/lib/audacious/Transport
/usr/lib/audacious/Visualization
/usr/share/applications/audacious.desktop
/usr/share/audacious
/usr/share/audacious/images
/usr/share/audacious/images/about-logo.png
/usr/share/audacious/images/album.png
/usr/share/audacious/images/appearance.png
/usr/share/audacious/images/audacious_eq.xpm
/usr/share/audacious/images/audacious_player.xpm
/usr/share/audacious/images/audacious_playlist.xpm
/usr/share/audacious/images/audio.png
/usr/share/audacious/images/blue.png
/usr/share/audacious/images/connectivity.png
/usr/share/audacious/images/menu_playlist.png
/usr/share/audacious/images/menu_plugin.png
/usr/share/audacious/images/menu_queue_toggle.png
/usr/share/audacious/images/playlist.png
/usr/share/audacious/images/plugins.png
/usr/share/audacious/images/replay_gain.png
/usr/share/doc/packages/audacious
/usr/share/doc/packages/audacious/AUTHORS
/usr/share/doc/packages/audacious/COPYING
/usr/share/doc/packages/audacious/NEWS
/usr/share/doc/packages/audacious/README
/usr/share/icons/hicolor/48x48/apps/audacious.png
/usr/share/icons/hicolor/scalable/apps/audacious.svg
/usr/share/man/man1/audacious.1.gz
/usr/share/man/man1/audtool.1.gz
/usr/share/pixmaps/audacious.png
/usr/share/pixmaps/audacious.svg
So, how do they create the menu entry?
Teuniz
July 14, 2011, 4:02pm
#4
I found the cause (I think), in ~/.config/menus/ if found a file “applications-kmenuedit.menu” with multiple menu entries for myapp.
Left from some older experiments I did with creating menu entries…
After deleting this file and running the script again, it works, the menu entry is now present.
Sorry for bothering.
openSUSE uses its own macros in the %install and %post sections of the rpm .spec file to create the .desktop file and update the menus. You can look at examples in OBS: https://build.opensuse.org/package/view_file?file=gedit.spec&package=gedit&project=openSUSE%3A11.4&srcmd5=e9209e3431d67ac45f6b0a3f7fe84e5b (gedit). If you create a rpm package of your application either locally with rpmbuild or in OBS, you can do that too.
Teuniz:
#!/bin/sh
#
cp myapp /usr/bin/
#
cp images/edf.png /usr/share/icons/
cp images/edf.png /usr/share/pixmaps/
#
cp myapp.desktop /usr/share/applications/
#
cp myapp.xml /usr/share/mime/packages/
#
#
update-mime-database /usr/share/mime/
#
Please can anybody help me and tell me what is missing here?
The command update-desktop-database is missing here. See man update-desktop-database .
Teuniz
July 24, 2011, 10:23am
#7
I removed the myapp.menu file and changed the install script:
#!/bin/sh
#
#
#
echo "copying files..."
#
cp -f myapp /usr/bin/
chmod 755 /usr/bin/myapp
#
mkdir -p /usr/share/doc/myapp/
cp -f 'doc/myapp manual.html' /usr/share/doc/myapp/
chmod 644 /usr/share/doc/myapp/"myapp manual.html"
#
cp -f images/edf.png /usr/share/icons/
chmod 644 /usr/share/icons/edf.png
cp -f images/edf.png /usr/share/pixmaps/
chmod 644 /usr/share/pixmaps/edf.png
#
cp -f images/edf.png /usr/share/icons/hicolor/16x16/apps/
chmod 644 /usr/share/icons/hicolor/16x16/apps/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/16x16/mimetypes/
chmod 644 /usr/share/icons/hicolor/16x16/mimetypes/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/22x22/apps/
chmod 644 /usr/share/icons/hicolor/22x22/apps/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/22x22/mimetypes/
chmod 644 /usr/share/icons/hicolor/22x22/mimetypes/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/24x24/apps/
chmod 644 /usr/share/icons/hicolor/24x24/apps/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/24x24/mimetypes/
chmod 644 /usr/share/icons/hicolor/24x24/mimetypes/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/32x32/apps/
chmod 644 /usr/share/icons/hicolor/32x32/apps/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/32x32/mimetypes/
chmod 644 /usr/share/icons/hicolor/32x32/mimetypes/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/36x36/apps/
chmod 644 /usr/share/icons/hicolor/36x36/apps/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/36x36/mimetypes/
chmod 644 /usr/share/icons/hicolor/36x36/mimetypes/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/48x48/apps/
chmod 644 /usr/share/icons/hicolor/48x48/apps/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/48x48/mimetypes/
chmod 644 /usr/share/icons/hicolor/48x48/mimetypes/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/64x64/apps/
chmod 644 /usr/share/icons/hicolor/64x64/apps/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/64x64/mimetypes/
chmod 644 /usr/share/icons/hicolor/64x64/mimetypes/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/72x72/apps/
chmod 644 /usr/share/icons/hicolor/72x72/apps/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/72x72/mimetypes/
chmod 644 /usr/share/icons/hicolor/72x72/mimetypes/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/96x96/apps/
chmod 644 /usr/share/icons/hicolor/96x96/apps/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/96x96/mimetypes/
chmod 644 /usr/share/icons/hicolor/96x96/mimetypes/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/128x128/apps/
chmod 644 /usr/share/icons/hicolor/128x128/apps/edf.png
cp -f images/edf.png /usr/share/icons/hicolor/128x128/mimetypes/
chmod 644 /usr/share/icons/hicolor/128x128/mimetypes/edf.png
#
cp -f images/application-x-edf.png /usr/share/icons/hicolor/16x16/mimetypes/
chmod 644 /usr/share/icons/hicolor/16x16/mimetypes/application-x-edf.png
cp -f images/application-x-bdf.png /usr/share/icons/hicolor/16x16/mimetypes/
chmod 644 /usr/share/icons/hicolor/16x16/mimetypes/application-x-bdf.png
cp -f images/application-x-edf.png /usr/share/icons/hicolor/22x22/mimetypes/
chmod 644 /usr/share/icons/hicolor/22x22/mimetypes/application-x-edf.png
cp -f images/application-x-bdf.png /usr/share/icons/hicolor/22x22/mimetypes/
chmod 644 /usr/share/icons/hicolor/22x22/mimetypes/application-x-bdf.png
cp -f images/application-x-edf.png /usr/share/icons/hicolor/24x24/mimetypes/
chmod 644 /usr/share/icons/hicolor/24x24/mimetypes/application-x-edf.png
cp -f images/application-x-bdf.png /usr/share/icons/hicolor/24x24/mimetypes/
chmod 644 /usr/share/icons/hicolor/24x24/mimetypes/application-x-bdf.png
cp -f images/application-x-edf.png /usr/share/icons/hicolor/32x32/mimetypes/
chmod 644 /usr/share/icons/hicolor/32x32/mimetypes/application-x-edf.png
cp -f images/application-x-bdf.png /usr/share/icons/hicolor/32x32/mimetypes/
chmod 644 /usr/share/icons/hicolor/32x32/mimetypes/application-x-bdf.png
cp -f images/application-x-edf.png /usr/share/icons/hicolor/36x36/mimetypes/
chmod 644 /usr/share/icons/hicolor/36x36/mimetypes/application-x-edf.png
cp -f images/application-x-bdf.png /usr/share/icons/hicolor/36x36/mimetypes/
chmod 644 /usr/share/icons/hicolor/36x36/mimetypes/application-x-bdf.png
cp -f images/application-x-edf.png /usr/share/icons/hicolor/48x48/mimetypes/
chmod 644 /usr/share/icons/hicolor/48x48/mimetypes/application-x-edf.png
cp -f images/application-x-bdf.png /usr/share/icons/hicolor/48x48/mimetypes/
chmod 644 /usr/share/icons/hicolor/48x48/mimetypes/application-x-bdf.png
cp -f images/application-x-edf.png /usr/share/icons/hicolor/64x64/mimetypes/
chmod 644 /usr/share/icons/hicolor/64x64/mimetypes/application-x-edf.png
cp -f images/application-x-bdf.png /usr/share/icons/hicolor/64x64/mimetypes/
chmod 644 /usr/share/icons/hicolor/64x64/mimetypes/application-x-bdf.png
cp -f images/application-x-edf.png /usr/share/icons/hicolor/72x72/mimetypes/
chmod 644 /usr/share/icons/hicolor/72x72/mimetypes/application-x-edf.png
cp -f images/application-x-bdf.png /usr/share/icons/hicolor/72x72/mimetypes/
chmod 644 /usr/share/icons/hicolor/72x72/mimetypes/application-x-bdf.png
cp -f images/application-x-edf.png /usr/share/icons/hicolor/96x96/mimetypes/
chmod 644 /usr/share/icons/hicolor/96x96/mimetypes/application-x-edf.png
cp -f images/application-x-bdf.png /usr/share/icons/hicolor/96x96/mimetypes/
chmod 644 /usr/share/icons/hicolor/96x96/mimetypes/application-x-bdf.png
cp -f images/application-x-edf.png /usr/share/icons/hicolor/128x128/mimetypes/
chmod 644 /usr/share/icons/hicolor/128x128/mimetypes/application-x-edf.png
cp -f images/application-x-bdf.png /usr/share/icons/hicolor/128x128/mimetypes/
chmod 644 /usr/share/icons/hicolor/128x128/mimetypes/application-x-bdf.png
#
cp -f myapp.desktop /usr/share/applications/
chmod 644 /usr/share/applications/myapp.desktop
#
cp -f myapp.xml /usr/share/mime/packages/
chmod 644 /usr/share/mime/packages/myapp.xml
#
#
#
if -x /usr/sbin/update-mime ]; then
echo "updating mime..."
cp -f myapp-mime /usr/lib/mime/packages/
chmod 644 /usr/lib/mime/packages/myapp-mime
update-mime
fi
#
if test -f /usr/bin/update-mime-database ; then
echo "updating mime database..."
/usr/bin/update-mime-database /usr/share/mime > /dev/null
fi
#
if test -f /usr/bin/update-desktop-database ; then
echo "updating desktop database..."
/usr/bin/update-desktop-database > /dev/null
fi
#
if test -f /sbin/SuSEconfig ; then
echo "running suseconfig..."
/sbin/SuSEconfig > /dev/null
fi
#
#
sync
#
#
echo "Done."
#
Now it works both on openSuse with KDE4 and Ubuntu with Gnome.
However, there’s only one weird thing left on opensuse.
In the menu-entry, myapp has a default icon (Pi symbol).
I don’t know why. In the recent used apps list, the myapp icon is used.
Also in the “recently installed” menu, the icon is ok.