diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e362c3..46fbc24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ separately in [CHANGELOG-DEPS.md](CHANGELOG-DEPS.md). ## Unreleased +- **Linux opens JSON and other text files in their associated application.** + File opening and text editing honor the desktop's inherited associations. + - **Going up to a parent folder selects the folder you came from and scrolls it into view, whichever way you go up.** Backspace and Back already did this; clicking a breadcrumb segment, a folder in the sidebar tree, or typing diff --git a/crates/ferail-shell-linux/src/lib.rs b/crates/ferail-shell-linux/src/lib.rs index d237d14..678491d 100644 --- a/crates/ferail-shell-linux/src/lib.rs +++ b/crates/ferail-shell-linux/src/lib.rs @@ -146,7 +146,13 @@ pub fn open_url(_url: &str) {} /// Ferail's stdio and reaped when the launcher exits. #[cfg(target_os = "linux")] pub fn open_with_default(path: &Path) -> std::io::Result<()> { - spawn_detached(std::process::Command::new("xdg-open").arg(path)) + let path = std::path::absolute(path)?; + match spawn_detached(std::process::Command::new("gio").arg("open").arg(&path)) { + Err(error) if error.kind() == std::io::ErrorKind::NotFound => { + spawn_detached(std::process::Command::new("xdg-open").arg(&path)) + } + result => result, + } } #[cfg(not(target_os = "linux"))] @@ -159,7 +165,7 @@ pub fn open_with_default(_path: &Path) -> std::io::Result<()> { /// portable equivalent of TextEdit/Notepad. #[cfg(target_os = "linux")] pub fn edit_text_file(path: &Path) -> std::io::Result<()> { - spawn_detached(std::process::Command::new("xdg-open").arg(path)) + open_with_default(path) } #[cfg(not(target_os = "linux"))]