No such interface org.freedesktop.portal.OpenURI on Arch Linux xfce

A while ago, my NewsFlash started to throw the following error when trying to open links:
Failed to open URL: ZBus Error: org.freedesktop.DBus.Error.UnknownMethod: No such interface "org.freedesktop.portal.OpenURI" on object at path /org/freedesktop/portal/desktop.

While I think I’ve experienced a similar issue with opening links before, I didn’t really want to take the ‘wait it out and hope for someone else to fix it’ approach this time.

Yesterday, I finally set out to identify the root cause and (hopefully) fix this issue.

Initially, I tried to compile the latest version of NewsFlash.
Unfortunately, it had the same issue.

I then cloned NewsFlash to search for how the Open Browser menu item is handled, tracing it to the following code:

use ashpd::desktop::open_uri::OpenFileRequest;
...

let ctx = glib::MainContext::default();
ctx.spawn_local(async move {
    if let Err(error) = OpenFileRequest::default().ask(ask).send_uri(&url).await {
        App::default().in_app_notifiaction(&i18n_f("Failed read URL: {}", &[&error.to_string()]));
    }
});

I tried to reproduce this usage of ashpd for opening links externally:

use ashpd::{desktop::open_uri::OpenFileRequest, url::Url};

#[tokio::main]
async fn main() {
    let url = "https://example.com";
    let url = Url::parse(url).unwrap();
    if let Err(error) = OpenFileRequest::default().ask(true).send_uri(&url).await {
        println!("{:?}", error);
    }
}

Unfortunately (or fortunately), it produced the same error.
This meant that it’s not a bug in NewsFlash.

Zbus(MethodError(OwnedErrorName(ErrorName(Str(Owned("org.freedesktop.DBus.Error.UnknownMethod")))), Some("No such interface “org.freedesktop.portal.OpenURI” on object at path /org/freedesktop/portal/desktop"), Msg { type: Error, sender: UniqueName(Str(Borrowed(":1.44"))), reply-serial: 15, body: Signature("s") }))

So I cloned ashpd. After struggling to produce a dev build of ashpd-demo, I eventually gave up and installed it using Flathub.

flatpak install com.belmoussaoui.ashpd.demo
flatpak run com.belmoussaoui.ashpd.demo

I clicked on the first couple of demos out of curiosity, and they all failed…

Unsurprisingly, the Open URI demo fails also.

ERROR ashpd_demo::portals::desktop::open_uri: Failed to open URI: ZBus Error: org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.OpenURI” on object at path /org/freedesktop/portal/desktop

At this stage, I performed a search on the Issues of ashpd and found no relevant results. A dead end… Perhaps it’s not an issue with ashpd either?

I went back to searching and eventually found a forum post, which links to a GitHub issue flatpak/xdg-desktop-portal #1077 No more OpenURI when using XDG_CURRENT_DESKTOP=sway and gtk portal.

This is great!

With some more trial and error, I settled on:

~/.config/xdg-desktop-portal/portals.conf

[preferred]
default=*

From one of the linked PRs.

After restarting, the links are working again! (for now…)

Edit: Note that this requires the package xdg-desktop-portal-gtk.

Next Post →