Bug 105734

Summary: xdg-open: prioritizes xdg_mime over $BROWSER
Product: Portland Reporter: Marco Sirabella <marco>
Component: xdg-utilsAssignee: Portland Bugs <portland-bugs>
Status: RESOLVED WONTFIX QA Contact:
Severity: enhancement    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: fix

Description Marco Sirabella 2018-03-25 14:01:06 UTC
Created attachment 138345 [details] [review]
fix

Even if $BROWSER is set, still prioritizes `xdg-mime query default x-scheme-handler/<schemetype>`.

Version: 
```
$ xdg-open --version
xdg-open 1.1.2
```

Steps to Reproduce:

```
$ BROWSER=echo xdg-open "https://bugs.freedesktop.org/"
```

Actual Behavior:
opens given URL in default web browser (mine is firefox)

Expected Behavior:
run $BROWSER <url>, in this case `echo https://bugs.freedesktop.org/`

if $BROWSER not found, fallback to xdg-mime defaults


I've found a hackish workaround for the time being:

```
$ DISPLAY="" BROWSER=echo xdg-open "https://bugs.freedesktop.org/"
https://bugs.freedesktop.org/
```

I'm attaching a patch for the reordering of priorities to fix this

Thanks,
-- Marco Sirabella
Comment 1 Rex Dieter 2018-03-25 14:46:45 UTC
I think this is by design... The fallback to using a browser is only used as a last resort.
Comment 2 Marco Sirabella 2018-03-26 02:39:54 UTC
Looking over this, the request I've made would open any URL that is not a local file with the $BROWSER variable only if set. This is http, but also ftp & others.

I think it makes sense to prioritize a user-defined $BROWSER variable as the user has explicitly stated "I want to use this application(s) as my browser".
Comment 3 Rex Dieter 2018-05-10 14:52:51 UTC
$BROWSER is still legacy (and will possibly be removed from xdg-utils in a future iteration).  http/https related mimetypes are the modern equivalent to setting preferred browsers

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.