Add ability to open files with system default application (#17231)

This commit is contained in:
KorigamiK
2024-09-10 14:36:36 -04:00
committed by GitHub
parent 06142f975b
commit ae3880e71a
10 changed files with 63 additions and 1 deletions
@@ -351,6 +351,19 @@ impl<P: LinuxClient + 'static> Platform for P {
self.reveal_path(path.to_owned());
}
fn open_with_system(&self, path: &Path) {
let executor = self.background_executor().clone();
let path = path.to_owned();
executor
.spawn(async move {
let _ = std::process::Command::new("xdg-open")
.arg(path)
.spawn()
.expect("Failed to open file with xdg-open");
})
.detach();
}
fn on_quit(&self, callback: Box<dyn FnMut()>) {
self.with_common(|common| {
common.callbacks.quit = Some(callback);