How to set the default web browser used to open URLs under i3

i3xdg-open

I have tried to set my default browser for opening URLs to Chromium using:

xdg-settings set default-web-browser chromium.desktop

(yes I checked out whether /usr/share/applications/chromium.desktop existed first before running this command and it does exist) and it returns:

xdg-settings: unknown desktop environment

i3 isn't a desktop environment so I can definitely understand this error, but is there a way around it? The reason I want xdg-open to open URLs using Chromium is that running notebook() from the SageMath command-line attempts to open the notebook in one's default web browser (using xdg-open). Presently this obviously fails (no browser, or application for that matter, is opened to the URL), so I'd like to get this to work which I believe will require me to get xdg-open to open URLs in Chromium.

Best Answer

Install perl-file-mimeinfo and configure it that way. See the Arch Wiki article on xdg-utils:

If no desktop environment is detected, MIME type detection falls back to using file which—ironically—does not implement the XDG standard. If you want xdg-open to use XDG MIME Applications without a desktop environment, you will need to install perl-file-mimeinfo or switch to one of the resource openers that support XDG MIME Applications.

Related Question