Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support for kioclient and x-www-browser #17

Merged
merged 5 commits into from
Oct 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,25 @@ fn open_browser_internal(browser: Browser, url: &str) -> Result<ExitStatus> {
match browser {
Browser::Default => open_on_unix_using_browser_env(url)
.or_else(|_| -> Result<ExitStatus> { Command::new("xdg-open").arg(url).status() })
.or_else(|r| -> Result<ExitStatus> {
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<ExitStatus> { Command::new("gvfs-open").arg(url).status() })
.or_else(|_| -> Result<ExitStatus> { Command::new("gnome-open").arg(url).status() }),
.or_else(|_| -> Result<ExitStatus> { Command::new("gnome-open").arg(url).status() })
.or_else(|_| -> Result<ExitStatus> {
Command::new("kioclient").arg("exec").arg(url).status()
})
.or_else(|e| -> Result<ExitStatus> {
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",
Expand Down