Skip to content

Instantly share code, notes, and snippets.

@likeablob
Created February 7, 2026 10:30
Show Gist options
  • Select an option

  • Save likeablob/8ba8a5b92e88663bbf3eae237920b4bf to your computer and use it in GitHub Desktop.

Select an option

Save likeablob/8ba8a5b92e88663bbf3eae237920b4bf to your computer and use it in GitHub Desktop.
Integrating Brave and KeePassXC (Flatpak ver)

Integrating Brave and KeePassXC (Flatpak ver)

# 1. Grant Brave access to KeePassXC's Flatpak files and runtime
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 com.brave.Browser

# 2. Create the wrapper script
cat > ~/.var/app/com.brave.Browser/config/BraveSoftware/Brave-Browser/keepassxc-proxy-wrapper.sh <<'EOF'
#!/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"

cd "$APP_PATH/files"
exec flatpak-spawn \
    --env=LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/app/lib:$APP_PATH/files/lib" \
    --app-path="$APP_PATH/files" \
    --usr-path="$RUNTIME_PATH/files" \
    -- bin/keepassxc-proxy "$@"
EOF
chmod +x ~/.var/app/com.brave.Browser/config/BraveSoftware/Brave-Browser/keepassxc-proxy-wrapper.sh

# 3. Register the wrapper as a NativeMessagingHost for the browser extension
cat > ~/.var/app/com.brave.Browser/config/BraveSoftware/Brave-Browser/NativeMessagingHosts/org.keepassxc.keepassxc_browser.json <<EOF
{
    "allowed_origins": [
        "chrome-extension://pdffhmdngciaglkoonimfcmckehcpafo/",
        "chrome-extension://oboonakemofpalcgghocfoadofidjkkk/"
    ],
    "description": "KeePassXC integration with native messaging support",
    "name": "org.keepassxc.keepassxc_browser",
    "path": "/home/${USER}/.var/app/com.brave.Browser/config/BraveSoftware/Brave-Browser/keepassxc-proxy-wrapper.sh",
    "type": "stdio"
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment