Add bar coloration option
This commit is contained in:
parent
bc2f19efd8
commit
5b94155b41
1 changed files with 14 additions and 0 deletions
14
src/main.rs
14
src/main.rs
|
@ -20,6 +20,8 @@ struct Arguments {
|
|||
nitrogen_dioxide: bool,
|
||||
#[clap(short, long = "o3", help = "Display ozone O3")]
|
||||
ozone: bool,
|
||||
#[clap(short, long, help = "Use color formatting tags for lemonbar and polybar")]
|
||||
bar: bool,
|
||||
}
|
||||
|
||||
#[derive(From, Debug)]
|
||||
|
@ -113,6 +115,15 @@ fn main() -> Result<(), Error> {
|
|||
} else {
|
||||
format!("{aqi} AQI")
|
||||
};
|
||||
if arguments.bar {
|
||||
print!("%{{F#{}}}", match aqi {
|
||||
150.. => "b48ead",
|
||||
100.. => "bf616a",
|
||||
50.. => "d08770",
|
||||
20.. => "ebcb8b",
|
||||
0.. => "a3be8c",
|
||||
});
|
||||
}
|
||||
print!("{}", descriptor);
|
||||
println!("{} {}",
|
||||
match aqi {
|
||||
|
@ -132,5 +143,8 @@ fn main() -> Result<(), Error> {
|
|||
0.. => display.green(), // Excellent 0-19
|
||||
}.bold()
|
||||
);
|
||||
if arguments.bar {
|
||||
print!("%{{F-}}");
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
|
Reference in a new issue