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 <yalterz@gmail.com>
This commit is contained in:
Lin Xianyi
2025-10-19 11:22:31 +00:00
committed by GitHub
parent 8c8447918f
commit 23cd5aa78a
8 changed files with 178 additions and 58 deletions
+26 -6
View File
@@ -118,16 +118,27 @@ pub enum Action {
CancelScreenshot,
#[knuffel(skip)]
ScreenshotTogglePointer,
Screenshot(#[knuffel(property(name = "show-pointer"), default = true)] bool),
Screenshot(
#[knuffel(property(name = "show-pointer"), default = true)] bool,
// Path; not settable from knuffel
Option<String>,
),
ScreenshotScreen(
#[knuffel(property(name = "write-to-disk"), default = true)] bool,
#[knuffel(property(name = "show-pointer"), default = true)] bool,
// Path; not settable from knuffel
Option<String>,
),
ScreenshotWindow(
#[knuffel(property(name = "write-to-disk"), default = true)] bool,
// Path; not settable from knuffel
Option<String>,
),
ScreenshotWindow(#[knuffel(property(name = "write-to-disk"), default = true)] bool),
#[knuffel(skip)]
ScreenshotWindowById {
id: u64,
write_to_disk: bool,
path: Option<String>,
},
ToggleKeyboardShortcutsInhibit,
CloseWindow,
@@ -364,19 +375,28 @@ impl From<niri_ipc::Action> for Action {
niri_ipc::Action::Spawn { command } => Self::Spawn(command),
niri_ipc::Action::SpawnSh { command } => Self::SpawnSh(command),
niri_ipc::Action::DoScreenTransition { delay_ms } => Self::DoScreenTransition(delay_ms),
niri_ipc::Action::Screenshot { show_pointer } => Self::Screenshot(show_pointer),
niri_ipc::Action::Screenshot { show_pointer, path } => {
Self::Screenshot(show_pointer, path)
}
niri_ipc::Action::ScreenshotScreen {
write_to_disk,
show_pointer,
} => Self::ScreenshotScreen(write_to_disk, show_pointer),
path,
} => Self::ScreenshotScreen(write_to_disk, show_pointer, path),
niri_ipc::Action::ScreenshotWindow {
id: None,
write_to_disk,
} => Self::ScreenshotWindow(write_to_disk),
path,
} => Self::ScreenshotWindow(write_to_disk, path),
niri_ipc::Action::ScreenshotWindow {
id: Some(id),
write_to_disk,
} => Self::ScreenshotWindowById { id, write_to_disk },
path,
} => Self::ScreenshotWindowById {
id,
write_to_disk,
path,
},
niri_ipc::Action::ToggleKeyboardShortcutsInhibit {} => {
Self::ToggleKeyboardShortcutsInhibit
}