Package: xdg-utils
Version: 1.0.2+cvs20100307-2
Severity: wishlist
Tags: patch
I'd really like midori to play xspf files using parole (a media player).
The mime type used by .xspf is application/xspf+xml. By default,
there's no application associated with them, but one can specify an
application with the following command:
xdg-mime default parole.desktop application/xspf+xml
This would work if xdg-mime saw an xspf as the correct mime type;
however, 'xdg-mime query filetype foo.xspf' results in
application/xml. This means that xdg-open will never launch the
correct application for xspf unless it is specifically told the mime
type (which midori knows, as the webpage which generates the xspf tells
it). As such, it would be nice if xdg-open supported an additional
argument specifying the mime type. Thus, one could do
xdg-open foo.xspf application/xspf+xml
And the correct mime type would be forced (and web browsers which
launch xdg-open on a file, can force the mime type).
Attached is a patch which adds support for this. If there's
another/better way to achieve this (especially since xdg-open is going
to be one of many things called; including exo-open, gvfs/gnome-open,
etc), I'm all ears.
--- xdg-open 2011-01-10 18:02:08.000000000 -0800
+++ /usr/bin/xdg-open 2011-01-10 18:21:04.000000000 -0800
@@ -40,7 +40,7 @@
Synopsis
-xdg-open { file | URL }
+xdg-open { file | URL } [mime]
xdg-open { --help | --manual | --version }
@@ -88,6 +88,10 @@
Opens the PNG image file /tmp/foobar.png in the user's default image viewing
application.
+xdg-open /tmp/moo.xspf application/xspf+xml
+
+Opens the XSPF playlist, forcing the mime type to application/xspf+xml.
+
_MANUALPAGE
}
@@ -98,7 +102,7 @@
Synopsis
-xdg-open { file | URL }
+xdg-open { file | URL } [mime]
xdg-open { --help | --manual | --version }
@@ -380,7 +384,11 @@
open_generic_xdg_mime()
{
- filetype=`xdg-mime query filetype "$1" | sed "s/;.*//"`
+ if [ -n "$2" ]; then
+ filetype="$2"
+ else
+ filetype=`xdg-mime query filetype "$1" | sed "s/;.*//"`
+ fi
default=`xdg-mime query default "$filetype"`
if [ -n "$default" ] ; then
xdg_user_dir="$XDG_DATA_HOME"
@@ -395,7 +403,7 @@
command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
command_exec=`which $command 2>/dev/null`
if [ -x "$command_exec" ] ; then
- $command_exec $1
+ $command_exec "$1"
if [ $? -eq 0 ]; then
exit_success
fi
@@ -421,7 +429,7 @@
check_input_file "$file"
- open_generic_xdg_mime "$file"
+ open_generic_xdg_mime "$file" "$2"
if [ -f /etc/debian_version ] &&
which run-mailcap 2>/dev/null 1>&2; then
@@ -450,6 +458,7 @@
[ x"$1" != x"" ] || exit_failure_syntax
url=
+mime=
while [ $# -gt 0 ] ; do
parm="$1"
shift
@@ -464,6 +473,10 @@
exit_failure_syntax "unexpected argument '$parm'"
fi
url="$parm"
+ if [ -n "$1" ]; then
+ mime="$1"
+ shift
+ fi
;;
esac
done
@@ -492,7 +505,7 @@
;;
generic)
- open_generic "$url"
+ open_generic "$url" "$mime"
;;
*)