Quick and easy way of making Chrome send bittorrent magnet links to a remote Transmission instance using its API on Ubuntu with xdg. This method does not require modifying any system files or xdg's scripts, whereas most of the examples I found on the Internet did require such hacks.
Chrome does not handle default applications, instead relying on the OS to manage that. The default handler in Ubuntu is xdg, which maps the MIME type to the default application. Extra tooling is required because xdg requires a registered desktop file, so you can't simply give it a command to run.
Steps:
-
Install the shell script
transmission-remote-magnet
ideally in/usr/local/bin
:ln -s ~/src/transmission-remote-magnet.bash transmission-remote-magnet
-
Install the desktop file, which is required for xdg to work and will likely require sudo:
desktop-file-install ./transmission-remote-magnet.desktop
-
Tell xdg to use the desktop file for the magnet MIME type:
xdg-mime default transmission-remote-magnet x-scheme-handler/magnet
-
Confirm that it works by either clicking on a magnet link in Chrome or from a shell:
xdg-open "magnet:?(bwah)
Recommended reading: