Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Oct 28, 2019
Merged
Changes from 4 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
14 changes: 13 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,20 @@ 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()
amodm marked this conversation as resolved.
Show resolved Hide resolved
})
.or_else(|_| -> Result<ExitStatus> { Command::new("x-www-browser").arg(url).status() }),
ssokolow marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll recommend you modify this to something like

.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)
            })

to allow for the tests to pass for now. It'll allow me to accept the PR. I'm realising that a larger fix for making the behaviour consistent, and reflecting those in the tests, will take me some time. So let's focus on closing this out for now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I'm just winding down for bed but I should have a commit for you tomorrow.

Copy link
Author

@ssokolow ssokolow Oct 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed the change but it's still blocking on the browser.

I have a headache and want to get to bed early, so I'll have to look into it further tomorrow, but I know it's not kioclient exec because, if I temporarily set my KDE handler for http:// and https:// URLs to something that's not already running, kioclient exec will launch the expected browser but will not block.

That leaves two possibilities I can think of off the top of my head:

  1. The code snippet you proposed is insufficient to keep it from waiting on a spawned child. I'll have to experiment tomorrow to rule this out.
  2. Travis-CI's configuration has changed since you last ran a test and, if you were to ask it to re-test your current HEAD, that would timeout and fail too.

I'm fairly certain it's not a difference between how my and Travis-CI's copies of commands behave, because we're both running systems based on Ubuntu Xenial (16.04 LTS).

I can see three ways option 2 might come about:

  1. Travis-CI might have started waiting for background processes to exit before considering a test run finished.
  2. Travis-CI might have changed the default browser.
  3. Travis-CI might have upgraded to a version of the browser which behaves differently under your test conditions.

Copy link
Owner

@amodm amodm Oct 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran a new build on master HEAD just now, and it passed.

_ => Err(Error::new(
ErrorKind::NotFound,
"Only the default browser is supported on this platform right now",
Expand Down