From f168dbb1e31e39268211a2ee4e435d1648dab633 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Tue, 12 Mar 2024 18:24:45 +0800 Subject: [PATCH] fix: graceful shutdown --- yazi-adaptor/src/ueberzug.rs | 17 +++++++++-------- yazi-boot/src/boot.rs | 7 +++++-- yazi-config/preset/keymap.toml | 24 ++++++++++++------------ yazi-core/src/which/commands/callback.rs | 2 +- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/yazi-adaptor/src/ueberzug.rs b/yazi-adaptor/src/ueberzug.rs index c2f9a6c1..3bcd905c 100644 --- a/yazi-adaptor/src/ueberzug.rs +++ b/yazi-adaptor/src/ueberzug.rs @@ -46,7 +46,7 @@ impl Ueberzug { tx.send(Some((path.to_path_buf(), rect)))?; Adaptor::shown_store(rect, (0, 0)); } else { - bail!("uninitialized ueberzug"); + bail!("uninitialized ueberzugpp"); } let path = path.to_owned(); @@ -66,12 +66,13 @@ impl Ueberzug { if let Some(tx) = &*DEMON { Ok(tx.send(None)?) } else { - bail!("uninitialized ueberzug"); + bail!("uninitialized ueberzugpp"); } } fn create_demon(adaptor: Adaptor) -> Result { - let result = Command::new("ueberzug") + // TODO: demon + let result = Command::new("ueberzugpp") .args(["layer", "-so", &adaptor.to_string()]) .kill_on_drop(true) .stdin(Stdio::piped()) @@ -79,7 +80,7 @@ impl Ueberzug { .spawn(); if let Err(ref e) = result { - warn!("ueberzug spawning failed: {}", e); + warn!("ueberzugpp spawning failed: {e}"); } Ok(result?) } @@ -98,9 +99,9 @@ impl Ueberzug { async fn send_command(child: &mut Child, cmd: Option<(PathBuf, Rect)>) -> Result<()> { let stdin = child.stdin.as_mut().unwrap(); if let Some((path, rect)) = cmd { - debug!("ueberzug rect before adjustment: {:?}", rect); + debug!("ueberzugpp rect before adjustment: {:?}", rect); let rect = Self::adjust_rect(rect); - debug!("ueberzug rect after adjustment: {:?}", rect); + debug!("ueberzugpp rect after adjustment: {:?}", rect); let s = format!( r#"{{"action":"add","identifier":"yazi","x":{},"y":{},"max_width":{},"max_height":{},"path":"{}"}}{}"#, @@ -111,10 +112,10 @@ impl Ueberzug { path.to_string_lossy(), "\n" ); - debug!("ueberzug command: {}", s); + debug!("ueberzugpp command: {}", s); stdin.write_all(s.as_bytes()).await?; } else { - debug!("ueberzug command: remove"); + debug!("ueberzugpp command: remove"); stdin .write_all(format!(r#"{{"action":"remove","identifier":"yazi"}}{}"#, "\n").as_bytes()) .await?; diff --git a/yazi-boot/src/boot.rs b/yazi-boot/src/boot.rs index 6380445c..d4f1f530 100644 --- a/yazi-boot/src/boot.rs +++ b/yazi-boot/src/boot.rs @@ -74,8 +74,11 @@ impl Boot { println!(" WAYLAND_DISPLAY: {:?}", env::var_os("WAYLAND_DISPLAY")); println!(" DISPLAY: {:?}", env::var_os("DISPLAY")); - println!("\nUeberzug"); - println!(" Version: {:?}", std::process::Command::new("ueberzug").arg("--version").output()); + println!("\nUeberzug++"); + println!( + " Version: {:?}", + std::process::Command::new("ueberzugpp").arg("--version").output() + ); println!("\nWSL"); println!( diff --git a/yazi-config/preset/keymap.toml b/yazi-config/preset/keymap.toml index a803ae7b..eb363ac0 100644 --- a/yazi-config/preset/keymap.toml +++ b/yazi-config/preset/keymap.toml @@ -106,18 +106,18 @@ keymap = [ { on = [ "N" ], run = "find_arrow --previous", desc = "Go to previous found file" }, # Sorting - { on = [ ",", "m" ], run = "sort modified --dir-first", desc = "Sort by modified time" }, - { on = [ ",", "M" ], run = "sort modified --reverse --dir-first", desc = "Sort by modified time (reverse)" }, - { on = [ ",", "c" ], run = "sort created --dir-first", desc = "Sort by created time" }, - { on = [ ",", "C" ], run = "sort created --reverse --dir-first", desc = "Sort by created time (reverse)" }, - { on = [ ",", "e" ], run = "sort extension --dir-first", desc = "Sort by extension" }, - { on = [ ",", "E" ], run = "sort extension --reverse --dir-first", desc = "Sort by extension (reverse)" }, - { on = [ ",", "a" ], run = "sort alphabetical --dir-first", desc = "Sort alphabetically" }, - { on = [ ",", "A" ], run = "sort alphabetical --reverse --dir-first", desc = "Sort alphabetically (reverse)" }, - { on = [ ",", "n" ], run = "sort natural --dir-first", desc = "Sort naturally" }, - { on = [ ",", "N" ], run = "sort natural --reverse --dir-first", desc = "Sort naturally (reverse)" }, - { on = [ ",", "s" ], run = "sort size --dir-first", desc = "Sort by size" }, - { on = [ ",", "S" ], run = "sort size --reverse --dir-first", desc = "Sort by size (reverse)" }, + { on = [ ",", "m" ], run = "sort modified", desc = "Sort by modified time" }, + { on = [ ",", "M" ], run = "sort modified --reverse", desc = "Sort by modified time (reverse)" }, + { on = [ ",", "c" ], run = "sort created", desc = "Sort by created time" }, + { on = [ ",", "C" ], run = "sort created --reverse", desc = "Sort by created time (reverse)" }, + { on = [ ",", "e" ], run = "sort extension", desc = "Sort by extension" }, + { on = [ ",", "E" ], run = "sort extension --reverse", desc = "Sort by extension (reverse)" }, + { on = [ ",", "a" ], run = "sort alphabetical", desc = "Sort alphabetically" }, + { on = [ ",", "A" ], run = "sort alphabetical --reverse", desc = "Sort alphabetically (reverse)" }, + { on = [ ",", "n" ], run = "sort natural", desc = "Sort naturally" }, + { on = [ ",", "N" ], run = "sort natural --reverse", desc = "Sort naturally (reverse)" }, + { on = [ ",", "s" ], run = "sort size", desc = "Sort by size" }, + { on = [ ",", "S" ], run = "sort size --reverse", desc = "Sort by size (reverse)" }, # Tabs { on = [ "t" ], run = "tab_create --current", desc = "Create a new tab using the current path" }, diff --git a/yazi-core/src/which/commands/callback.rs b/yazi-core/src/which/commands/callback.rs index 7dd4100c..ef0fc5fe 100644 --- a/yazi-core/src/which/commands/callback.rs +++ b/yazi-core/src/which/commands/callback.rs @@ -27,7 +27,7 @@ impl Which { }; if opt.tx.try_send(opt.idx).is_err() { - error!("callback: send error"); + error!("which callback: send error"); } } }