Extend switch-layout action to accept layout index (#1045)

* Extend switch-layout action to accept layout index

* Update src/input/mod.rs

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
This commit is contained in:
Evgeny Zemtsov
2025-01-26 20:09:01 +01:00
committed by GitHub
parent d665079b84
commit baa0518912
2 changed files with 15 additions and 2 deletions
+6 -1
View File
@@ -668,6 +668,8 @@ pub enum LayoutSwitchTarget {
Next,
/// The previous configured layout.
Prev,
/// The specific layout by index.
Index(u8),
}
/// Output actions that niri can perform.
@@ -1174,7 +1176,10 @@ impl FromStr for LayoutSwitchTarget {
match s {
"next" => Ok(Self::Next),
"prev" => Ok(Self::Prev),
_ => Err(r#"invalid layout action, can be "next" or "prev""#),
other => match other.parse() {
Ok(layout) => Ok(Self::Index(layout)),
_ => Err(r#"invalid layout action, can be "next", "prev" or a layout index"#),
},
}
}
}