[Workaround] Plasma Browser Integration working with Brave/Chromium Flatpak on Wayland

Hey everyone,

I managed to get Plasma Browser Integration fully working with Brave Browser
(Flatpak)
on Fedora 43 + KDE Plasma 6 (Wayland). Since this is a pain point
for many users on immutable distros and Flatpak-based setups, I wanted to share
the solution.

The Problem

The extension shows “Failed to connect to the native host” on any
Chromium-based Flatpak browser. There are two root causes:

  1. The “args” field in native messaging JSON doesn’t work correctly inside
    the Flatpak sandbox — the browser tries to execute the extension URI as a
    command (bwrap: execvp chrome-extension://… No such file or directory)
  2. plasma-browser-integration-host hangs when called from a Flatpak
    context because it tries to connect to the XDG Desktop Portal via D-Bus and
    blocks indefinitely

The Fix (3 small files)

The approach uses two wrapper scripts to bridge the Flatpak sandbox boundary.

Step 1 — Host-side wrapper (requires sudo):

    sudo tee /usr/local/bin/plasma-browser-integration-host-wrapper << 'EOF'
    #!/bin/bash
    export QT_NO_XDG_DESKTOP_PORTAL=1
    exec /usr/bin/plasma-browser-integration-host "$@"
    EOF
    sudo chmod +x /usr/local/bin/plasma-browser-integration-host-wrapper

Step 2 — Sandbox-side wrapper:

    cat > ~/.var/app/com.brave.Browser/data/plasma-browser-integration-wrapper.sh << 'EOF'
    #!/bin/bash
    exec flatpak-spawn --host /usr/local/bin/plasma-browser-integration-host-wrapper "$@"
    EOF
    chmod +x ~/.var/app/com.brave.Browser/data/plasma-browser-integration-wrapper.sh

Step 3 — Native messaging JSON (replace <HOME_DIR> with your home path):

mkdir -p ~/.var/app/com.brave.Browser/config/BraveSoftware/Brave-Browser/NativeMessagingHosts

cat > ~/.var/app/com.brave.Browser/config/BraveSoftware/Brave-Browser/NativeMessagingHosts/org.kde.plasma.browser_integration.json << ENDJSON
{
    "name": "org.kde.plasma.browser_integration",
    "description": "KDE Plasma Integration",
    "path": "<HOME_DIR>/.var/app/com.brave.Browser/data/plasma-browser-integration-wrapper.sh",
    "type": "stdio",
    "allowed_origins": [
        "chrome-extension://cimiefiiaegbelhefglklhhakcgmhkai/"
    ]
}
ENDJSON

Step 4 — Restart Brave and the extension should connect immediately.

Result

Everything works: media controls, KRunner tab search, download notifications.

Notes

  • This should work for any Chromium-based Flatpak browser (Chrome, Edge,
    Vivaldi) — just adapt the paths.
  • It’s a workaround until xdg-native-messaging-proxy lands in browsers.
  • Full technical details posted on bugs.kde.org #502759
    (https://bugs.kde.org/show_bug.cgi?id=502759).

Hope this helps someone!

This should already work for Flatpak browser but the integration tool for that might not create files in all locations yet (since each browser might have a different one).

Thanks! I checked and indeed the flatpak-integrator doesn’t seem to
create the manifest for Brave (com.brave.Browser). The NativeMessagingHosts
path for Brave Flatpak is:

~/.var/app/com.brave.Browser/config/BraveSoftware/Brave-Browser/NativeMessagingHosts/

Also, even after manually placing the manifest, there are two additional issues
I had to work around:

  1. The “args” field in the JSON manifest causes a bwrap error inside the Brave
    sandbox — the path must point directly to a wrapper script with no “args”
  2. plasma-browser-integration-host hangs on XDG Desktop Portal D-Bus calls
    when invoked from a Flatpak context — requires QT_NO_XDG_DESKTOP_PORTAL=1