xdg-open opens magnet links in the browser instead of the default bittorrent application (suggested patch)
Submitted by cyr..@..il.com
Assigned to Rex Dieter
Created attachment 124435 Patch to fix the x-scheme open issue.
I'm using version 1.1.1 on Arch Linux, but that wasn't available in the drop-down so I chose the closest version.
Opening a magnet link with xdg-open will open that link in the default bittorrent application.
Opening a magnet link with xdg-open opens the link with the browser set by $BROWSER.
Steps to reproduce:
- Set the BROWSER environment variable to any browser.
- The magnet link will be opened by the browser instead of the default application for magnet links.
I first noticed this issue when clicking a magnet link in Chromium/Chrome would open a new tab. Since Chromium uses xdg-open, I first checked to make sure
xdg-mime query default x-scheme-handler/magnet returned my default torrent application. Since xdg-mime reported the correct default application, I looked in xdg-open to see why it was opening my browser instead. I managed to find the problem code here:
... 817 if [ -n "$BROWSER" ]; then 818 open_envvar "$1" 819 fi 820 821 if [ -n "$DISPLAY" ]; then 822 open_generic_xdg_x_scheme_handler "$1" 823 fi 824 825 # if BROWSER variable is not set, check some well known browsers instead 826 if [ x"$BROWSER" = x"" ]; then 827 BROWSER=www-browser:links2:elinks:links:lynx:w3m 828 if [ -n "$DISPLAY" ]; then 829 BROWSER=x-www-browser:firefox:iceweasel:seamonkey:mozilla:epiphany:konqueror:chromium-browser:google-chrome:$BROWSER 830 fi 831 fi 832 833 open_envvar "$1" 834 835 exit_failure_operation_impossible "no method available for opening '$1'" ...
Since $BROWSER is defined in my .bashrc, the first code path (
open_envvar "$1") and
open_generic_xdg_x_scheme_handler "$1" is never reached. To fix this, I removed lines 817-819. Since the
open_envvar "$1" will happen eventually if $DISPLAY is not set, this shouldn't drastically change how this piece of code works.
For convenience, I've attached the patch I made to this message.
Patch 124435, "Patch to fix the x-scheme open issue.":