lthms' avatar, a hand drawing looking person, wearing a headset, close to a window on a raining night
Thomas Letan
lthms · he/him

Did you come across something which caught your attention? Don’t hesitate to shoot me an email in my public inbox.

 Published on

Teaching Firefox About slack:// URLs

I’ve been using Slack at $WORK for the past 5 (!) years. I don't know why, but it looks like Firefox does not know what to do with the slack:// URLs out of the boxTry logging in Slack when your browser does not let Slack know authentication concluded successfully. The worst thing? Sometimes it works, sometimes it doesn’t. . It could be an issue on my side—wouldn’t be the first time!—but in case you are suffering from the same issue, I have found that I can provision my laptop with a so-called Firefox policy to fix this annoyance.

Caution

Firefox only supports a single policies.json file. If you happen to already have one installed at /usr/lib/firefox/distribution/policies.json, you will need to merge the policies manually.

{
  "policies": {
    "Handlers": {
      "schemes": {
        "slack": {
          "action": "useHelperApp",
          "ask": false,
          "path": "/usr/lib/firefox-slack-policy/open-slack"
        }
      }
    }
  }
}

This will only work if you also install the companion script open-slack.

#!/bin/sh
exec xdg-open "$@"

These two files together tell Firefox to use xdg-open in place of gio open. If I understand correctly, the latter needs an explicit entry in the mimeapps.list file to select an application to handle mimetypes it is not familiar with (like x-scheme-handler/slack) even if you have a .desktop file with the appropriate MimeType declaration. I have no idea why, especially considering that mimeinfo.cache correctly resolves x-scheme-handler/slack on my machine.

Anyway, now at least I can log in Slack without issue. I made a small AUR package of it, so if you are an ArchLinux user affected by this bug and without a pre-existing Firefox entreprise policy, feel free to install firefox-slack-policy  and call it a day.