How to open a magnet link with the Chrome browser on GNU/Linux

Prerequisites: xdg-utils
Tl;dr YouTube

xdg-openWhen clicking a magnet link, the Chrome (or Chromium) browser will launch an external application to handle the link (remember it’s a URI, hence the external protocol request message). Anyhow, if your system doesn’t have an application associated with magnet links, then the result will be no action at all.

As shown in the Chrome dialog box, we are informed that xdg-open will handle the request.

xdg-open opens a file or URL in the user's preferred application.

The application I prefer to handle magnet links is the Transmission bittorrent client.¬†On KDE, it’s preferable to use the Qt implementation (transmission-qt.desktop).
A desktop file describes how a particular program is to be launched under the “Desktop Entry Standard”.

The transmission-qt.desktop file has the following format:

[Desktop Entry]
Name=Qtransmission Bittorrent Client
GenericName=BitTorrent Client
Comment=Download and share files over BitTorrent
Exec=transmission-qt %U
...

By using xdg-mime, we’ll make Transmission the default application for opening magnet files.

xdg-mime - command line tool for querying information about file type handling and adding descriptions for new file types

Finally, by using the “default” command, we’re left with a simple one-liner to finish off the job:

xdg-mime default transmission-qt.desktop x-scheme-handler/magnet

The x-scheme-handler indicates that the magnet link is a URI scheme.
After restarting the Chrome browser, magnet links are now handled by Transmission by default.

Thank you for reading!
Feel free to waste more time by subscribing to my RSS feed or check out the human-readable sitemap for more content.

Related posts