Skip to content

Commit ec5f483

Browse files
authored
Add support for gio open on Linux
1 parent ccbae5d commit ec5f483

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/lib.rs

+17-7
Original file line numberDiff line numberDiff line change
@@ -252,18 +252,28 @@ mod unix {
252252
use which::which;
253253

254254
pub fn that<T: AsRef<OsStr> + Sized>(path: T) -> Result<ExitStatus> {
255-
["xdg-open", "gnome-open", "kde-open", "wslview"] // Open handlers
255+
["xdg-open", "gio", "gnome-open", "kde-open", "wslview"] // Open handlers
256256
.iter()
257257
.find(|it| which(it).is_ok()) // find the first handler that exists
258258
.ok_or(Error::from_raw_os_error(0)) // If not found, return err
259259
.and_then(|program| {
260260
// If found run the handler
261-
Command::new(program)
262-
.stdout(Stdio::null())
263-
.stderr(Stdio::null())
264-
.arg(path.as_ref())
265-
.spawn()?
266-
.wait()
261+
if program.to_string() == "gio" {
262+
Command::new(program)
263+
.stdout(Stdio::null())
264+
.stderr(Stdio::null())
265+
.arg("open")
266+
.arg(path.as_ref())
267+
.spawn()?
268+
.wait()
269+
} else {
270+
Command::new(program)
271+
.stdout(Stdio::null())
272+
.stderr(Stdio::null())
273+
.arg(path.as_ref())
274+
.spawn()?
275+
.wait()
276+
}
267277
})
268278
}
269279

0 commit comments

Comments
 (0)