ZBus Error `failed to read from socket` for `register_host_app`
In a GTK4 app, I've tried setting app-id via register_host_app for when the app is not running in a sandbox in main() (before gtk::Application is created) and in ApplicationImpl::activate() but I always get this same error:
tokio_runtime().block_on(async move {
_ = ashpd::register_host_app(ashpd::AppID::from_str(APP_ID).unwrap())
.await
.inspect_err(|err| tracing::error!("{err:#}"));
});
ZBus Error: I/O error: failed to read from socket
I'm not sure if I'm using it improperly or what.
Gtk4 does the registration automatically, it should not be necessary to call this manually. I suspect it fails because it is called yo early ot because your portals on the host are too outdated.
I was trying to setup auto start for when the app is not in sandbox using ashpd::BackgroundRequest::auto_start() but it doesn't seem to work (no desktop entry in ~/.config/autostart), and with no visible errors at that. And, so I thought setting app id via register_host_app would make it work, but that's not working out either as shown above. If gtk already sets it then I'm not why autostart is not working when in native.
Here's what I did for autostart:
_ = dbg!(
Background::request()
.identifier(ashpd::WindowIdentifier::from_native(&self.native().unwrap()).await)
.auto_start(true)
.send()
.await
);
Here are the portal versions on my arch system:
libportal 0.9.1-2
libportal-gtk3 0.9.1-2
libportal-gtk4 0.9.1-2
xdg-desktop-portal 1.20.3-2
xdg-desktop-portal-gnome 49.0-1
xdg-desktop-portal-gtk 1.15.3-1