Skip to content

Commit

Permalink
fix: don't unnecessarily reject launchers on linux.
Browse files Browse the repository at this point in the history
Previously it probably went through 5 launers assuming they don't work
before falling back to `xdg-open` which is usually present.

Now it will use the first launcher that it could invoke.
  • Loading branch information
Byron committed Mar 6, 2023
1 parent 8aa9bce commit 55dc10d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ pub fn command<T: AsRef<OsStr>>(path: T) -> Command {
for (command, args) in &open_handlers {
let result = Command::new(command).status_without_output();

if let Ok(status) = result {
if status.success() {
let mut cmd = Command::new(command);
cmd.args(*args);
return cmd;
};
if let Ok(_) = result {
let mut cmd = Command::new(command);
cmd.args(*args);
dbg!(&cmd);
return cmd;
};
}

// fallback to xdg-open
// fallback to xdg-open, even though we know it's probably not working at this point.
let (command, args) = &open_handlers[0];
let mut cmd = Command::new(command);
cmd.args(*args);
Expand Down

0 comments on commit 55dc10d

Please sign in to comment.