Bug 23280

Summary: xdg-open should use xdg-mime instead of run-mailcap when no DE detected
Product: Portland Reporter: Lei Zhang <thestig>
Component: xdg-utilsAssignee: Fathi Boudra <fabo>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: look up mime type and association and run associated app if possible

Description Lei Zhang 2009-08-12 18:23:09 UTC
Upstreaming https://bugs.launchpad.net/ubuntu/+source/xdg-utils/+bug/220765

Original report:
----
When no desktop environment is detected, xdg-open falls back to a generic mechanism based on run-mailcap. This is rather limited as it depends on file extensions. It would seem better to use file or probably xdg-mime to choose how to open the file.

The mime type could be fetched with:

file --mime "$1"

and extracted from the output and prepended to the filename before passing to run-mailcap.

However, it looks to me like a better option would be to use xdg-mime, since xdg-mime query default "$1" will give you the default application to open the file.
----


IMO, xdg-mime does a better job of figuring out what program to open a given file with. xdg-mime also uses defaults.list, which might be part of a fd.o spec? OTOH, run-mailcap is a Debian-ism that doesn't exist on all distros. Thus in open_generic(), we should try to use xdg-mime first before falling back to run-mailcap.
Comment 1 Timothy Goya 2009-11-04 22:12:18 UTC
Created attachment 30974 [details] [review]
look up mime type and association and run associated app if possible

The original comes from Slackware's xdg-utils-1.0.2.  Not sure where run-mailcap fits in here exactly..
Comment 2 Lei Zhang 2010-02-18 11:27:59 UTC
Ping. The patch posted in comment 1 looks decent. Can you review?
Comment 3 Fathi Boudra 2010-02-21 06:31:14 UTC
The proposed patch couldn't be commited as-is.
I commited another fix based on the proposal:
http://webcvs.freedesktop.org/portland/portland/xdg-utils/scripts/xdg-open.in?r1=1.25&r2=1.26

Let me know if you have a regression or if I missed something ;)

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.