2021-03-15 10:40:52 +00:00
|
|
|
use crate::config::ModuleConfig;
|
2019-09-30 12:10:35 +00:00
|
|
|
|
2021-03-31 15:31:55 +00:00
|
|
|
use serde::Serialize;
|
2019-09-30 12:10:35 +00:00
|
|
|
use starship_module_config_derive::ModuleConfig;
|
|
|
|
|
2021-03-31 15:31:55 +00:00
|
|
|
#[derive(Clone, ModuleConfig, Serialize)]
|
2019-09-30 12:10:35 +00:00
|
|
|
pub struct BatteryConfig<'a> {
|
2020-07-07 22:45:32 +00:00
|
|
|
pub full_symbol: &'a str,
|
|
|
|
pub charging_symbol: &'a str,
|
|
|
|
pub discharging_symbol: &'a str,
|
2021-01-01 11:16:55 +00:00
|
|
|
pub unknown_symbol: &'a str,
|
|
|
|
pub empty_symbol: &'a str,
|
2020-07-07 22:45:32 +00:00
|
|
|
pub display: Vec<BatteryDisplayConfig<'a>>,
|
2019-09-30 12:10:35 +00:00
|
|
|
pub disabled: bool,
|
2020-07-07 22:45:32 +00:00
|
|
|
pub format: &'a str,
|
2019-09-30 12:10:35 +00:00
|
|
|
}
|
|
|
|
|
2021-03-15 10:40:52 +00:00
|
|
|
impl<'a> Default for BatteryConfig<'a> {
|
|
|
|
fn default() -> Self {
|
2019-09-30 12:10:35 +00:00
|
|
|
BatteryConfig {
|
2021-04-03 11:10:45 +00:00
|
|
|
full_symbol: " ",
|
|
|
|
charging_symbol: " ",
|
|
|
|
discharging_symbol: " ",
|
|
|
|
unknown_symbol: " ",
|
|
|
|
empty_symbol: " ",
|
2020-07-07 22:45:32 +00:00
|
|
|
format: "[$symbol$percentage]($style) ",
|
2021-04-17 11:52:46 +00:00
|
|
|
display: vec![BatteryDisplayConfig::default()],
|
2019-09-30 12:10:35 +00:00
|
|
|
disabled: false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 11:52:46 +00:00
|
|
|
#[derive(Clone, ModuleConfig, Serialize)]
|
2020-07-07 22:45:32 +00:00
|
|
|
pub struct BatteryDisplayConfig<'a> {
|
2019-09-30 12:10:35 +00:00
|
|
|
pub threshold: i64,
|
2020-07-07 22:45:32 +00:00
|
|
|
pub style: &'a str,
|
2021-04-17 11:52:46 +00:00
|
|
|
pub charging_symbol: Option<&'a str>,
|
|
|
|
pub discharging_symbol: Option<&'a str>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Default for BatteryDisplayConfig<'a> {
|
|
|
|
fn default() -> Self {
|
|
|
|
BatteryDisplayConfig {
|
|
|
|
threshold: 10,
|
|
|
|
style: "red bold",
|
|
|
|
charging_symbol: None,
|
|
|
|
discharging_symbol: None,
|
|
|
|
}
|
|
|
|
}
|
2019-09-30 12:10:35 +00:00
|
|
|
}
|