Fix(wayland): improve error message when xdg-desktop-portal is unavailable #12897 (#14543)

* Fix: Wayland requires higher version of linux distro. Please try X11 desktop or change your OS. #12897

* refactor(wayland): optimize translation keys for binary size and improve dbus matching
This commit is contained in:
Qusai Ismael
2026-03-17 05:37:20 +00:00
committed by GitHub
parent 02da7132e7
commit 9d8df6a226
50 changed files with 159 additions and 100 deletions

View File

@@ -10,7 +10,8 @@ use std::io;
use crate::{
client::{
SCRAP_OTHER_VERSION_OR_X11_REQUIRED, SCRAP_UBUNTU_HIGHER_REQUIRED, SCRAP_X11_REQUIRED,
SCRAP_OTHER_VERSION_OR_X11_REQUIRED, SCRAP_UBUNTU_HIGHER_REQUIRED,
SCRAP_X11_REQUIRED, SCRAP_XDP_PORTAL_UNAVAILABLE,
},
platform::linux::is_x11,
};
@@ -56,10 +57,15 @@ fn map_err_scrap(err: String) -> io::Error {
}
} else {
try_log(&err);
if err.contains("org.freedesktop.portal")
|| err.contains("pipewire")
|| err.contains("dbus")
let err_lower = err.to_ascii_lowercase();
if err_lower.contains("org.freedesktop.portal")
|| err_lower.contains("dbus")
|| err_lower.contains("d-bus")
{
// The portal D-Bus interface is unreachable. This typically means
// xdg-desktop-portal has crashed... for more info, see: Issue #12897
io::Error::new(io::ErrorKind::Other, SCRAP_XDP_PORTAL_UNAVAILABLE)
} else if err_lower.contains("pipewire") {
io::Error::new(io::ErrorKind::Other, SCRAP_OTHER_VERSION_OR_X11_REQUIRED)
} else {
io::Error::new(io::ErrorKind::Other, SCRAP_X11_REQUIRED)