Fixing the 1password for Linux URL scheme handler

When my employer switched 1Password over to Single Sign On (SSO), the callback from browser back to the Linux app wasn’t working for me.

It just failed silently because Firefox suppressed errors about 1Password’s URL scheme handler not being registered, so after going through the Azure SSO portal screens and hitting “Continue” on the “Are you trying to sign in to 1Password?” prompt, nothing happened at all.

After some spelunking through the developer tools we got a hint:

Prevented navigation to “https://login.microsoftonline.com/appverify” due to an unknown protocol.

Sure enough, xdg-mime query default x-scheme-handler/onepassword returned no result. Unusual, as 1password does register it:

$ grep x-scheme-handler /usr/share/applications/1password.desktop
MimeType=x-scheme-handler/onepassword;

Running sudo update-desktop-database wouldn’t resolve this either, so in the end I registered it manually:

xdg-mime default 1password.desktop x-scheme-handler/onepassword

After going through these motions, I had to fix one more issue, which most people shouldn’t hit, but I’m documenting it for completeness anyway. To run 1password with a proper resolution and avoid fuzzy text on HiDPI displays, it’s necessary to patch the exec line 1password is launched with in order to force Electron to use the Ozone rendering backend.

This requires adding the --enable-features=UseOzonePlatform --ozone-platform=wayland flags, for which I have an automated script (patch-electron-desktop-files) as part of my dotfiles. This leaves the Exec line in 1password.desktop looking as follows:

Exec=/opt/1Password/1password %U --ozone-platform=wayland --enable-features=UseOzonePlatform --enable-features=WaylandWindowDecorations

It appears 1password is sensitive to the location of the %U argument, so while the desktop app was now correctly being invoked by Firefox after the SSO sign-in, things still weren’t working.

It’s necessary to ensure that URL parameter ends up last, so that it looks as follows, and only then will everything work correctly:

Exec=/opt/1Password/1password --ozone-platform=wayland --enable-features=UseOzonePlatform --enable-features=WaylandWindowDecorations %U