diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-01-13 21:20:52 -0500 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-01-13 21:20:52 -0500 |
commit | 1a50f8279b5bd5b0a0266d6435fbdc4f2934c6ee (patch) | |
tree | c7bc2f23177b7eb12129839e2552bf0e962ef205 | |
parent | c6e477cae753fe2ec3453a59e12fc2c5c95462a6 (diff) |
add forking capabilities via xdg_open
-rw-r--r-- | Cargo.lock | 4 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | config/joshuto.toml | 1 | ||||
-rw-r--r-- | src/commands/open_file.rs | 10 | ||||
-rw-r--r-- | src/config/general/app.rs | 1 | ||||
-rw-r--r-- | src/config/general/app_crude.rs | 3 |
6 files changed, 15 insertions, 6 deletions
@@ -502,9 +502,9 @@ checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" [[package]] name = "open" -version = "1.7.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcea7a30d6b81a2423cc59c43554880feff7b57d12916f231a79f8d6d9470201" +checksum = "176ee4b630d174d2da8241336763bb459281dddc0f4d87f72c3b1efc9a6109b7" dependencies = [ "pathdiff", "winapi", @@ -16,7 +16,7 @@ filetime = "^0" globset = "^0" lazy_static = "^1" libc = "^0" -open = "^1" +open = "^2" rand = "^0" rustyline = "^4" serde = "^1" diff --git a/config/joshuto.toml b/config/joshuto.toml index cda9bcd..f7b3bbb 100644 --- a/config/joshuto.toml +++ b/config/joshuto.toml @@ -1,4 +1,5 @@ xdg_open = false +xdg_open_fork = false use_trash = true watch_files = true diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs index 767b890..3a2f0f2 100644 --- a/src/commands/open_file.rs +++ b/src/commands/open_file.rs @@ -65,9 +65,13 @@ pub fn open(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult res?; } } else if config.xdg_open { - backend.terminal_drop(); - open::that(paths[0].as_path())?; - backend.terminal_restore()?; + if config.xdg_open_fork { + open::that_in_background(paths[0].as_path()); + } else { + backend.terminal_drop(); + open::that(paths[0].as_path())?; + backend.terminal_restore()?; + } } else { open_with_helper(context, backend, options, files)?; } diff --git a/src/config/general/app.rs b/src/config/general/app.rs index a7602d4..41bb604 100644 --- a/src/config/general/app.rs +++ b/src/config/general/app.rs @@ -8,6 +8,7 @@ use crate::error::JoshutoResult; pub struct AppConfig { pub use_trash: bool, pub xdg_open: bool, + pub xdg_open_fork: bool, pub watch_files: bool, pub _display_options: DisplayOption, pub _preview_options: PreviewOption, diff --git a/src/config/general/app_crude.rs b/src/config/general/app_crude.rs index 20add72..1598427 100644 --- a/src/config/general/app_crude.rs +++ b/src/config/general/app_crude.rs @@ -24,6 +24,8 @@ pub struct AppConfigCrude { pub use_trash: bool, #[serde(default)] pub xdg_open: bool, + #[serde(default)] + pub xdg_open_fork: bool, #[serde(default = "default_true")] pub watch_files: bool, #[serde(default, rename = "display")] @@ -39,6 +41,7 @@ impl From<AppConfigCrude> for AppConfig { Self { use_trash: crude.use_trash, xdg_open: crude.xdg_open, + xdg_open_fork: crude.xdg_open_fork, watch_files: crude.watch_files, _display_options: DisplayOption::from(crude.display_options), _preview_options: PreviewOption::from(crude.preview_options), |