From 23cd5aa78a26ccf57c6a7993313e42a5c39d43d8 Mon Sep 17 00:00:00 2001 From: Lin Xianyi Date: Sun, 19 Oct 2025 11:22:31 +0000 Subject: Add --path argument for niri msg screenshot* commands (#2126) * Check for empty screenshot parent before creating Avoids a warning. * Add --path argument for niri msg screenshot* commands * fix --------- Co-authored-by: Ivan Molodetskikh --- src/ui/hotkey_overlay.rs | 20 ++++++++++---------- src/ui/screenshot_ui.rs | 3 +++ 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'src/ui') diff --git a/src/ui/hotkey_overlay.rs b/src/ui/hotkey_overlay.rs index 67997fc8..541affb8 100644 --- a/src/ui/hotkey_overlay.rs +++ b/src/ui/hotkey_overlay.rs @@ -263,7 +263,7 @@ fn collect_actions(config: &Config) -> Vec<&Action> { // Screenshot is not as important, can omit if not bound. if let Some(bind) = binds .iter() - .find(|bind| matches!(bind.action, Action::Screenshot(_))) + .find(|bind| matches!(bind.action, Action::Screenshot(_, _))) { actions.push(&bind.action); } @@ -479,7 +479,7 @@ fn action_name(action: &Action) -> String { String::from("Switch Focus Between Floating and Tiling") } Action::ToggleOverview => String::from("Open the Overview"), - Action::Screenshot(_) => String::from("Take a Screenshot"), + Action::Screenshot(_, _) => String::from("Take a Screenshot"), Action::Spawn(args) => format!( "Spawn {}", args.first().unwrap_or(&String::new()) @@ -620,7 +620,7 @@ mod tests { #[test] fn test_format_bind() { // Not bound. - assert_snapshot!(check("", Action::Screenshot(true)), @" (not bound) : Take a Screenshot"); + assert_snapshot!(check("", Action::Screenshot(true, None)), @" (not bound) : Take a Screenshot"); // Bound with a default title. assert_snapshot!( @@ -628,7 +628,7 @@ mod tests { r#"binds { Mod+P { screenshot; } }"#, - Action::Screenshot(true), + Action::Screenshot(true, None), ), @" Super + P : Take a Screenshot" ); @@ -639,7 +639,7 @@ mod tests { r#"binds { Mod+P hotkey-overlay-title="Hello" { screenshot; } }"#, - Action::Screenshot(true), + Action::Screenshot(true, None), ), @" Super + P : Hello" ); @@ -651,7 +651,7 @@ mod tests { Mod+P { screenshot; } Print { screenshot; } }"#, - Action::Screenshot(true), + Action::Screenshot(true, None), ), @" Super + P : Take a Screenshot" ); @@ -663,7 +663,7 @@ mod tests { Mod+P { screenshot; } Print hotkey-overlay-title="My Cool Bind" { screenshot; } }"#, - Action::Screenshot(true), + Action::Screenshot(true, None), ), @" PrtSc : My Cool Bind" ); @@ -675,7 +675,7 @@ mod tests { Mod+P hotkey-overlay-title="First" { screenshot; } Print hotkey-overlay-title="My Cool Bind" { screenshot; } }"#, - Action::Screenshot(true), + Action::Screenshot(true, None), ), @" Super + P : First" ); @@ -687,7 +687,7 @@ mod tests { Mod+P { screenshot; } Print hotkey-overlay-title=null { screenshot; } }"#, - Action::Screenshot(true), + Action::Screenshot(true, None), ), @"None" ); @@ -699,7 +699,7 @@ mod tests { Mod+P hotkey-overlay-title="Hello" { screenshot; } Print hotkey-overlay-title=null { screenshot; } }"#, - Action::Screenshot(true), + Action::Screenshot(true, None), ), @" Super + P : Hello" ); diff --git a/src/ui/screenshot_ui.rs b/src/ui/screenshot_ui.rs index 3200cae4..7c03d36e 100644 --- a/src/ui/screenshot_ui.rs +++ b/src/ui/screenshot_ui.rs @@ -63,6 +63,7 @@ pub enum ScreenshotUi { open_anim: Animation, clock: Clock, config: Rc>, + path: Option, }, } @@ -141,6 +142,7 @@ impl ScreenshotUi { screenshots: HashMap, default_output: Output, show_pointer: bool, + path: Option, ) -> bool { if screenshots.is_empty() { return false; @@ -235,6 +237,7 @@ impl ScreenshotUi { open_anim, clock: clock.clone(), config: config.clone(), + path, }; self.update_buffers(); -- cgit