This is a topic on which apparently a ton of outdated information is floating around - does anyone know how to register a URL handler for a new scheme (e.g. “foo://”) in Firefox, which can then be associated with an application to handle such URLs?
It has to work with current versions of Firefox (55/56). Please only respond if you have successfully done this yourself.
OK, I finally figured it out - this is how it works in 16.04 at least - tested with Firefox 55 and 57:
Suppose you want to associate an application that handles myprotocol://… URLs.
-
create ~/.local/share/applications/myapp.desktop which launches the app,
similar to this (the last line is essential, as is the %u argument in Exec=):[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=myapp.sh %u
Name=My App
Comment=
Icon=
Categories=Application;Network;
MimeType=x-scheme-handler/myprotocol; -
start Firefox and open about:config
-
create new boolean “network.protocol-handler.expose.myprotocol”, set to “false” (do not use “true”!)
-
open a “myprotocol://whatever” URL in Firefox
=> you should get a window asking you to associate it with the application, where you can also check a “remember this” option so you won’t be asked again next time (which will also set the flag to “true”)