Windows 10 will reach EOS (end of support) on October 14, 2025. For more information, see this article.

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

External protocol handler does not get arguments

  • 2 replies
  • 1 has this problem
  • 1 view
  • Last reply by slagt

more options

Dear community,

The question I am about to ask is the same I asked on SuperUser quick a while ago, but got no answer: https://superuser.com/q/1300709/879171


I have a bash script to handle magnet links. But it looks like firefox does not send any arguments to the script. To demonstrate the problem, the following script is enough:

 #! /bin/bash
 echo "argc: $#"

I wrapped this script into an Automator application (because Firefox requires a *.app for the handler). I used the Run Shell Script Actions, set the Pass input option to as arguments and the Shell option to /bin/bash. I also used a Display Notification Actions to display the result.

In Firefox about:config, I set the 'network.protocol-handler.expose.magnet' entry to 'false' as suggested.

1. Firefox does run the application when I click on magnet:// links, 2. From Firefox, the Finder notification always displays 'argc: 0', 3. If I drag & drop a file onto the application icon in Finder, the message is 'argc: 1'.

I use Firefox 58.0.2 and macOS High Sierra 10.13.3.


Problem is still true today with Firefox 61.0.2 and macOS High Sierra 10.13.6

I also tried to mimic the properties of the 'mailto' protocol by adding the following properties: network.protocol-handler.external.magnet -> TRUE network.protocol-handler.warn-external.magnet -> FALSE

Below is a list of all the available bash variables when script is executed. The list is obtained by running '(set -o posix; set)'.

Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.Cv7mgR3VJ2/Render
BASH=/bin/bash
BASH_ARGC=([0]="0")
BASH_ARGV=()
BASH_EXECUTION_STRING='( set -o posix ; set ) > ~/Desktop/mozilla.txt'
BASH_LINENO=()
BASH_REMATCH=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="2" [2]="57" [3]="1" [4]="release" [5]="x86_64-apple-darwin17")
BASH_VERSION='3.2.57(1)-release'
DIRSTACK=()
DISPLAY=/private/tmp/com.apple.launchd.9sK8D5xtMv/org.macosforge.xquartz:0
EUID=502
GROUPS=()
HOME=/Users/*****
HOSTNAME=mac-*****
HOSTTYPE=x86_64
IFS='

'

LOGNAME=*****
MACHTYPE=x86_64-apple-darwin17
OPTERR=1
OPTIND=1
OSTYPE=darwin17
PATH=/usr/bin:/bin:/usr/sbin:/sbin
PIPESTATUS=([0]="0")
POSIXLY_CORRECT=y
PPID=7785
PS4='+ '
PWD=/Users/*****
SHELL=/usr/local/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments:posix
SHLVL=1
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.xhDg6k4yjb/Listeners
TERM=dumb
TMPDIR=/var/folders/7d/64z_mqvd10jfhq0_k_044jhw0000gp/T/
UID=502
USER=*****
XPC_FLAGS=0x0
XPC_SERVICE_NAME='com.apple.automator.*****.22644'
_=posix
__CF_USER_TEXT_ENCODING=0x1F6:0x0:0x0

Any help is appreciated.

Dear community, The question I am about to ask is the same I asked on SuperUser quick a while ago, but got no answer: https://superuser.com/q/1300709/879171 ---------------------------------------------------------------------------- I have a bash script to handle magnet links. But it looks like firefox does not send any arguments to the script. To demonstrate the problem, the following script is enough: #! /bin/bash echo "argc: $#" I wrapped this script into an Automator application (because Firefox requires a *.app for the handler). I used the Run Shell Script Actions, set the Pass input option to as arguments and the Shell option to /bin/bash. I also used a Display Notification Actions to display the result. In Firefox about:config, I set the 'network.protocol-handler.expose.magnet' entry to 'false' as suggested. 1. Firefox does run the application when I click on magnet:// links, 2. From Firefox, the Finder notification always displays 'argc: 0', 3. If I drag & drop a file onto the application icon in Finder, the message is 'argc: 1'. I use Firefox 58.0.2 and macOS High Sierra 10.13.3. ---------------------------------------------------------------------------- Problem is still true today with Firefox 61.0.2 and macOS High Sierra 10.13.6 I also tried to mimic the properties of the 'mailto' protocol by adding the following properties: network.protocol-handler.external.magnet -> TRUE network.protocol-handler.warn-external.magnet -> FALSE Below is a list of all the available bash variables when script is executed. The list is obtained by running '(set -o posix; set)'. : Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.Cv7mgR3VJ2/Render : BASH=/bin/bash : BASH_ARGC=([0]="0") : BASH_ARGV=() : BASH_EXECUTION_STRING='( set -o posix ; set ) > ~/Desktop/mozilla.txt' : BASH_LINENO=() : BASH_REMATCH=() : BASH_SOURCE=() : BASH_VERSINFO=([0]="3" [1]="2" [2]="57" [3]="1" [4]="release" [5]="x86_64-apple-darwin17") : BASH_VERSION='3.2.57(1)-release' : DIRSTACK=() : DISPLAY=/private/tmp/com.apple.launchd.9sK8D5xtMv/org.macosforge.xquartz:0 : EUID=502 : GROUPS=() : HOME=/Users/***** : HOSTNAME=mac-***** : HOSTTYPE=x86_64 : IFS=' ' : LOGNAME=***** : MACHTYPE=x86_64-apple-darwin17 : OPTERR=1 : OPTIND=1 : OSTYPE=darwin17 : PATH=/usr/bin:/bin:/usr/sbin:/sbin : PIPESTATUS=([0]="0") : POSIXLY_CORRECT=y : PPID=7785 : PS4='+ ' : PWD=/Users/***** : SHELL=/usr/local/bin/bash : SHELLOPTS=braceexpand:hashall:interactive-comments:posix : SHLVL=1 : SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.xhDg6k4yjb/Listeners : TERM=dumb : TMPDIR=/var/folders/7d/64z_mqvd10jfhq0_k_044jhw0000gp/T/ : UID=502 : USER=***** : XPC_FLAGS=0x0 : XPC_SERVICE_NAME='com.apple.automator.*****.22644' : _=posix : __CF_USER_TEXT_ENCODING=0x1F6:0x0:0x0 Any help is appreciated.

All Replies (2)

more options

Are you trying to do something that isn't by default a FF function?

more options

I think I am trying to use a FF function, but that does not seem to work as expected.

What I want is Firefox to run my custom application when I click on a magnet link, passing as argument the magnet link I have clicked on.

If I click a link pointing to mailto:foo@bar, then my mail client open and a new message starts with foo@bar in the "To:" field. Somehow, my mail client is able to get the argument foo@bar.

If I click a link pointing to magnet:my-link, I expect my custom application to get, somewhere, somehow, the argument my-link. But I don't, my-link is nowhere to be found, not as argument nor environment variable.

Firefox does run my custom application. I can see the notification. But I have no way to get the link I have clicked on. I expected the link to be passed as argument, but it does not seem to be the case (actually no arguments is passed to my application). The link is not passed as environment variable neither.

Modified by slagt