-
Notifications
You must be signed in to change notification settings - Fork 38
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
How does open URL work? #323
Comments
This is done here Line 1653 in 6bcc592
You could try to replace this open::open call by https://docs.rs/opener/latest/opener/fn.open_browser.html. Aparently, it will use then the default browser. |
Thanks a lot for the quick response. Honestly, I can't figure out how opener really uses xdg-open. I have a custom shell script called xdg-open that I use to open files but it seems that this does not work. They are using fn open_with_system_xdg_open(path: &OsStr) -> io::Result<Child> {
Command::new("xdg-open")
.arg(path)
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()
} to open the file at first. This should just launch my custom script but it doesn't for some reason. Edit: Even weirder thing is that the opener crate works fine when I try it on its own. |
Let's try to debug your script then. You can apply this patch diff --git a/src/app.rs b/src/app.rs
index ecb7a27..4d4e0c4 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -1647,12 +1647,29 @@ fn to_emoji(s: &str) -> Option<&str> {
}
fn open_url(message: &Message, url_regex: &Regex) -> Option<()> {
+ use std::io::Write;
+
let text = message.message.as_ref()?;
let m = url_regex.find(text)?;
let url = m.as_str();
- if let Err(error) = opener::open(url) {
+
+ let mut file = std::fs::OpenOptions::new()
+ .create(true)
+ .append(true)
+ .open("/tmp/open.log")
+ .unwrap();
+ writeln!(&mut file, "opening {url}").unwrap();
+
+ if let Err(error) = std::process::Command::new("xdg-open")
+ .arg(url)
+ .stdin(std::process::Stdio::null())
+ .stdout(file.try_clone().unwrap())
+ .stderr(file.try_clone().unwrap())
+ .spawn()
+ {
error!(url, %error, "failed to open");
}
+
Some(())
} When opening an url, it will write the stdout/stderr of
|
Sorry for the late response, unfortunately I am unable to test this because for some reason I can't compile zerocopy when trying to build with cargo build. Weirdly enough this works when I am using cargo install. Edit: |
I have just discovered that pressing enter on a selected URL message is supposed to open said URL. Unfortunately, this does not work on my system but I am not getting any error messages. How does gurk URL opening work under the hood? I am guessing that my system is missing some requirements for this.
The text was updated successfully, but these errors were encountered: