Very surprisingly, out-of-the-box, Firefox does not offer a way to directly open URLs of certain mime-type (or containing certain file extensions) with external programs.
Another usecase for this would be calling external programs for streaming.
There are even a few old bug reports for Firefox (dating back a decade ago). The developers seem to acknowledge the general issue, but they are still open - sometimes principal architectural issues are mentioned. Other browsers like Opera/Internet-Explorer support such open-URL-with-external-program feature. A few comments mention different addons to work-around this - but they are all seem to be discontinued/not-working.
I've come up with following solution:
part 1: addon
Install the Firefox addon URL Relay. With that you can configure URL patterns that are opened with an external program.
part 2: shell script
Use a shell script like this:
#!/usr/bin/bash
set -e
set -u
# for testing
set -x
if [ $# -lt 1 ] ; then
cat <<EOF
call: $0 TORRENT_URL_1 TORRENT_URL_2 ...
Adds torrent URLs to a remote transmission daemon.
EOF
exit 1
fi
function quote()
{
for i in "$@"; do
echo --add "'"$i"'"
done
}
HOST=example.org
AUTH="--auth juser:geheim"
ADDR=transmissiond.example.org:5432
TRANSMISSION_REMOTE=transmission-remote
ssh $HOST $TRANSMISSION_REMOTE $ADDR $AUTH `quote "$@"` # "'$1'"
The quoting scheme is used to protect against whitespace/shell-meta-characters in URLs, allthough firefox is probably sane enough not to include those.
part 3: configure URL relay
Use something like \.torrent$ as URL pattern, the script location as executable and just %URL% as parameter.
additional notes
The addon URL Relay does not seem to give feedback on erroneous exit status.
Thus, one can wrap the above script with at now such that an email is sent
in the error case.