diff --git a/yazi-boot/src/args.rs b/yazi-boot/src/args.rs index 07e8c12f..1732b92c 100644 --- a/yazi-boot/src/args.rs +++ b/yazi-boot/src/args.rs @@ -34,4 +34,8 @@ pub struct Args { /// Print version #[arg(short = 'V', long)] pub version: bool, + + /// Set the YAZI_ID environment variable (integer) + #[arg(long)] + pub id: Option, } diff --git a/yazi-boot/src/boot.rs b/yazi-boot/src/boot.rs index 9f412674..5016cfb1 100644 --- a/yazi-boot/src/boot.rs +++ b/yazi-boot/src/boot.rs @@ -21,6 +21,8 @@ pub struct Boot { pub flavor_dir: PathBuf, pub plugin_dir: PathBuf, pub state_dir: PathBuf, + + pub yazi_id: Option, } impl Boot { @@ -184,6 +186,7 @@ impl Default for Boot { plugin_dir: config_dir.join("plugins"), config_dir, state_dir: Xdg::state_dir(), + yazi_id: ARGS.id.clone(), } } } diff --git a/yazi-dds/src/lib.rs b/yazi-dds/src/lib.rs index 6a50bcde..90f4d022 100644 --- a/yazi-dds/src/lib.rs +++ b/yazi-dds/src/lib.rs @@ -17,6 +17,7 @@ pub use sendable::*; use server::*; pub use state::*; use stream::*; +use yazi_boot::BOOT; #[cfg(unix)] pub static USERS_CACHE: yazi_shared::RoCell = yazi_shared::RoCell::new(); @@ -25,7 +26,7 @@ pub fn init() { let (tx, rx) = tokio::sync::mpsc::unbounded_channel(); // Client - ID.init(yazi_shared::timestamp_us()); + ID.init(BOOT.yazi_id.unwrap_or(yazi_shared::timestamp_us())); PEERS.with(Default::default); QUEUE_TX.init(tx); QUEUE_RX.init(rx);