MIME types and associations and .desktops

Window managers, icon programs, widgets, etc.
Post Reply
Message
Author
User avatar
darkcity
Posts: 2534
Joined: Sun 23 May 2010, 19:16
Location: near here
Contact:

MIME types and associations and .desktops

#1 Post by darkcity »

Adding MIME types is harder is Puppy than some Linux.

Take for example Audacity, it includes the mime xml file
/usr/share/mime/packages/audacity.xml

Normally the update-mime-database command would run after installation. This has been remove - along with the standard freedesktop.org xml descriptions (about 2MB).

the update-mime-database takes all the descriptions in /usr/share/mime/packages/ and compiles them in various files including /usr/share/mime/globs

This isn't a problem for associating currently existing MIME types. But Audacity wants to add its x-audacity-project type - for its native filetype.

----

work around - simply add the new mime types to the end of non-binary files in files in /usr/share/mime/

here for my script examples for adding and remove mime type (and associations) for my Audacity packaging

/pinstall

Code: Select all

#!/bin/bash
#post-install script.

#add mime-type (without using update-mime-database)
echo application/x-audacity-project:*.aup >> /usr/share/mime/globs
echo 50:application/x-audacity-project:*.aup >> /usr/share/mime/globs2
echo application/x-audacity-project text/xml >> /usr/share/mime/subclasses
echo application/x-audacity-project >> /usr/share/mime/types

#link MIME actions to .desktop description
#-direct-action  (can be over ridden with ~/.config/rox.sourceforge.net/MIME-types/application_x-audacity-project)
ln -s /usr/share/applications/audacity.desktop ~/Choices/MIME-types/application_x-audacity-project

#-right-click association to aup, flac, mp3, ogg, wav
if ! [ -d ~/.config/rox.sourceforge.net/OpenWith/.application_x-audacity-project ] ; then mkdir ~/.config/rox.sourceforge.net/OpenWith/.application_x-audacity-project ; fi
ln -s /usr/share/applications/audacity.desktop ~/.config/rox.sourceforge.net/OpenWith/.application_x-audacity-project/audacity
if ! [ -d ~/.config/rox.sourceforge.net/OpenWith/.audio_x-flac/ ] ; then mkdir ~/.config/rox.sourceforge.net/OpenWith/.audio_x-flac/ ; fi
ln -s /usr/share/applications/audacity.desktop ~/.config/rox.sourceforge.net/OpenWith/.audio_x-flac/audacity
if ! [ -d ~/.config/rox.sourceforge.net/OpenWith/.audio_mpeg/ ] ; then mkdir ~/.config/rox.sourceforge.net/OpenWith/.audio_mpeg/ ; fi
ln -s /usr/share/applications/audacity.desktop ~/.config/rox.sourceforge.net/OpenWith/.audio_mpeg/audacity
if ! [ -d ~/.config/rox.sourceforge.net/OpenWith/.audio_x-vorbis+ogg/ ] ; then mkdir ~/.config/rox.sourceforge.net/OpenWith/.audio_x-vorbis+ogg/ ; fi
ln -s /usr/share/applications/audacity.desktop ~/.config/rox.sourceforge.net/OpenWith/.audio_x-vorbis+ogg/audacity
if ! [ -d ~/.config/rox.sourceforge.net/OpenWith/.audio_x-wav/ ] ; then mkdir ~/.config/rox.sourceforge.net/OpenWith/.audio_x-wav/ ; fi
ln -s /usr/share/applications/audacity.desktop ~/.config/rox.sourceforge.net/OpenWith/.audio_x-wav/audacity

#-open-with association (open any file with this app)
ln -s /usr/share/applications/audacity.desktop ~/.config/rox.sourceforge.net/OpenWith/audacity
/puninstall

Code: Select all

#!/bin/bash
#post-uninstall script.
#remove mime-type on uninstall (without using update-mime-database)
sed -i '/application\/x-audacity-project:\*.aup$/ d' /usr/share/mime/globs
sed -i '/50:application\/x-audacity-project:\*.aup$/ d' /usr/share/mime/globs2
sed -i '/application\/x-audacity-project text\/xml$/ d' /usr/share/mime/subclasses
sed -i '/application\/x-audacity-project$/ d' /usr/share/mime/types

#rm links to MIME actions to .desktop description
#-direct-action  (can be over ridden with ~/.config/rox.sourceforge.net/MIME-types/application_x-audacity-project)
rm ~/Choices/MIME-types/application_x-audacity-project

#-right-click association to aup, flac, mp3, ogg, wav
rm ~/.config/rox.sourceforge.net/OpenWith/.application_x-audacity-project/audacity
rm ~/.config/rox.sourceforge.net/OpenWith/.audio_x-flac/audacity
rm ~/.config/rox.sourceforge.net/OpenWith/.audio_mpeg/audacity
rm ~/.config/rox.sourceforge.net/OpenWith/.audio_x-vorbis+ogg/audacity
rm ~/.config/rox.sourceforge.net/OpenWith/.audio_x-wav/audacity

#-open-with association (open any file with this app)
rm ~/.config/rox.sourceforge.net/OpenWith/audacity
a script could be written to interpret mime xml files and append globs etc , would this be worth while?

----
/usr/local/apps the red herring?

there is no need to use this directory if a .desktop entry exists, passing files to the .desktop works even (maybe oddly) without the "$@"

Post Reply