I’m going through a bunch of browsers at the moment to find one I’m happy with. Wanted to share how I get the KeePassXC-browser addon to work with flatpaks.

Flatpaks are sandboxed by design, so getting them to talk to each other needs a go-between. I adapted this from a Chromium guide. It works for me, hopefully maybe it’ll help someone.

1. Run this command

flatpak override --user \
  --filesystem={/var/lib,xdg-data}/flatpak/{app/org.keepassxc.KeePassXC,runtime/org.kde.Platform}:ro \
  --filesystem=xdg-run/app/org.keepassxc.KeePassXC:create \
  io.gitlab.librewolf-community

2. Create a wrapper script

  • The script goes in the following location: ~/.var/app/io.gitlab.librewolf-community/data/bin/keepassxc-proxy-wrapper.sh
#!/bin/bash

APP_REF="org.keepassxc.KeePassXC/x86_64/stable"

for inst in "$HOME/.local/share/flatpak" "/var/lib/flatpak"; do
    if [ -d "$inst/app/$APP_REF" ]; then
        FLATPAK_INST="$inst"
        break
    fi
done
[ -z "$FLATPAK_INST" ] && exit 1

APP_PATH="$FLATPAK_INST/app/$APP_REF/active"

RUNTIME_REF=$(awk -F'=' '$1=="runtime" { print $2 }' < "$APP_PATH/metadata")
RUNTIME_PATH="$FLATPAK_INST/runtime/$RUNTIME_REF/active"

exec flatpak-spawn \
    --env=LD_LIBRARY_PATH=/app/lib \
    --app-path="$APP_PATH/files" \
    --usr-path="$RUNTIME_PATH/files" \
    -- keepassxc-proxy "$@"
  • Then run the command chmod +x ~/.var/app/io.gitlab.librewolf-community/data/bin/keepassxc-proxy-wrapper.sh

3. Manually create a native messaging host file

  • It goes in the following location: ~/.var/app/io.gitlab.librewolf-community/.librewolf/native-messaging-hosts/org.keepassxc.keepassxc_browser.json
  • Create the NativeMessagingHosts directory if it doesn’t exist.
  • Substitute (USERNAME) for your username.
{  
   "allowed_extensions": [  
       "keepassxc-browser@keepassxc.org"  
   ],  
   "description": "KeePassXC integration with native messaging support",  
   "name": "org.keepassxc.keepassxc_browser",  
   "path": "/home/(USERNAME)/.var/app/io.gitlab.librewolf-community/data/bin/keepassxc-proxy-wrapper.sh",  
   "type": "stdio"  
}

4. Enable browser integration within KeePassXC (if it isn’t already)

  • Within KeePassXC: Tools > Settings > Browser Integration, enable Firefox

5. Restart Librewolf