diff --git a/src/lib.rs b/src/lib.rs index 6ff7b16..7ee5b6c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -270,8 +270,25 @@ fn open_browser_internal(browser: Browser, url: &str) -> Result { match browser { Browser::Default => open_on_unix_using_browser_env(url) .or_else(|_| -> Result { Command::new("xdg-open").arg(url).status() }) + .or_else(|r| -> Result { + if let Ok(desktop) = ::std::env::var("XDG_CURRENT_DESKTOP") { + if desktop == "KDE" { + return Command::new("kioclient").arg("exec").arg(url).status(); + } + } + Err(r) // If either `if` check fails, fall through to the next or_else + }) .or_else(|_| -> Result { Command::new("gvfs-open").arg(url).status() }) - .or_else(|_| -> Result { Command::new("gnome-open").arg(url).status() }), + .or_else(|_| -> Result { Command::new("gnome-open").arg(url).status() }) + .or_else(|_| -> Result { + Command::new("kioclient").arg("exec").arg(url).status() + }) + .or_else(|e| -> Result { + if let Ok(_child) = Command::new("x-www-browser").arg(url).spawn() { + return Ok(ExitStatusExt::from_raw(0)); + } + Err(e) + }), _ => Err(Error::new( ErrorKind::NotFound, "Only the default browser is supported on this platform right now",