Support displaying the layout name
This commit is contained in:
parent
24068579f6
commit
92e989f26c
13
src/main.rs
13
src/main.rs
@ -15,6 +15,7 @@ struct Flags {
|
|||||||
title: bool,
|
title: bool,
|
||||||
urgency: bool,
|
urgency: bool,
|
||||||
viewstag: bool,
|
viewstag: bool,
|
||||||
|
layout: bool,
|
||||||
output: Option<String>,
|
output: Option<String>,
|
||||||
seat: Option<String>,
|
seat: Option<String>,
|
||||||
}
|
}
|
||||||
@ -26,6 +27,7 @@ impl Flags {
|
|||||||
title: false,
|
title: false,
|
||||||
urgency: false,
|
urgency: false,
|
||||||
viewstag: false,
|
viewstag: false,
|
||||||
|
layout: false,
|
||||||
output: None,
|
output: None,
|
||||||
seat: None,
|
seat: None,
|
||||||
}
|
}
|
||||||
@ -39,6 +41,8 @@ struct Env {
|
|||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
flags: Flags,
|
flags: Flags,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
layout: Option<String>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
title: Option<String>,
|
title: Option<String>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
tags: Option<BTreeMap<String, Tags>>,
|
tags: Option<BTreeMap<String, Tags>>,
|
||||||
@ -55,6 +59,7 @@ impl Env {
|
|||||||
let flags = configuration();
|
let flags = configuration();
|
||||||
Env {
|
Env {
|
||||||
title: None,
|
title: None,
|
||||||
|
layout: None,
|
||||||
tags: flags.tags.then(BTreeMap::new),
|
tags: flags.tags.then(BTreeMap::new),
|
||||||
urgency: flags.urgency.then(BTreeMap::new),
|
urgency: flags.urgency.then(BTreeMap::new),
|
||||||
viewstag: flags.viewstag.then(BTreeMap::new),
|
viewstag: flags.viewstag.then(BTreeMap::new),
|
||||||
@ -68,6 +73,7 @@ impl Env {
|
|||||||
|| self.tags.is_some()
|
|| self.tags.is_some()
|
||||||
|| self.urgency.is_some()
|
|| self.urgency.is_some()
|
||||||
|| self.viewstag.is_some()
|
|| self.viewstag.is_some()
|
||||||
|
|| self.layout.is_some()
|
||||||
{
|
{
|
||||||
println!("{}", serde_json::to_string(self).unwrap());
|
println!("{}", serde_json::to_string(self).unwrap());
|
||||||
}
|
}
|
||||||
@ -200,6 +206,11 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
zriver_output_status_v1::Event::LayoutName {
|
||||||
|
name,
|
||||||
|
} => {
|
||||||
|
env.layout = Some(name);
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -241,6 +252,7 @@ fn configuration() -> Flags {
|
|||||||
"--urgency" | "-u" => default.urgency = true,
|
"--urgency" | "-u" => default.urgency = true,
|
||||||
"--title" | "-w" => default.title = true,
|
"--title" | "-w" => default.title = true,
|
||||||
"--tags" | "-t" => default.tags = true,
|
"--tags" | "-t" => default.tags = true,
|
||||||
|
"--layout" | "-l" => default.layout = true,
|
||||||
"--views-tag" | "-vt" => default.viewstag = true,
|
"--views-tag" | "-vt" => default.viewstag = true,
|
||||||
"--help" | "-h" => {
|
"--help" | "-h" => {
|
||||||
print!("Usage: ristate [option]\n\n");
|
print!("Usage: ristate [option]\n\n");
|
||||||
@ -250,6 +262,7 @@ fn configuration() -> Flags {
|
|||||||
print!(" --views-tag | -vt the tag of all views\n");
|
print!(" --views-tag | -vt the tag of all views\n");
|
||||||
print!(" --seat | -s <string> select the seat\n");
|
print!(" --seat | -s <string> select the seat\n");
|
||||||
print!(" --output | -o <string> select the output\n");
|
print!(" --output | -o <string> select the output\n");
|
||||||
|
print!(" --layout | -l <string> display the name of the layout\n");
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
Loading…
Reference in New Issue
Block a user