summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Knaack <davidkna@users.noreply.github.com>2021-01-01 12:16:55 +0100
committerGitHub <noreply@github.com>2021-01-01 12:16:55 +0100
commit6de4bb01f4d42a526f3c6294f249fd6c024d5ef8 (patch)
treee4887eaf4bde2242e377eebf5db869bff72d6c0b
parentf7a55dde8e6266b4fcd448f5f0f0c19903fdeef7 (diff)
feat(battery): make module behaviour more obvious (#1950)
-rw-r--r--docs/config/README.md29
-rw-r--r--docs/presets/README.md5
-rw-r--r--src/configs/battery.rs14
-rw-r--r--src/modules/battery.rs11
4 files changed, 25 insertions, 34 deletions
diff --git a/docs/config/README.md b/docs/config/README.md
index c52150672..02381655b 100644
--- a/docs/config/README.md
+++ b/docs/config/README.md
@@ -316,26 +316,17 @@ The module is only visible when the device's battery is below 10%.
### Options
-| Option | Default | Description |
-| -------------------- | --------------------------------- | ------------------------------------------------- |
-| `full_symbol` | `"•"` | The symbol shown when the battery is full. |
-| `charging_symbol` | `"⇡"` | The symbol shown when the battery is charging. |
-| `discharging_symbol` | `"⇣"` | The symbol shown when the battery is discharging. |
-| `format` | `"[$symbol$percentage]($style) "` | The format for the module. |
-| `display` | [link](#battery-display) | Display threshold and style for the module. |
-| `disabled` | `false` | Disables the `battery` module. |
+| Option | Default | Description |
+| -------------------- | --------------------------------- | --------------------------------------------------- |
+| `full_symbol` | `""` | The symbol shown when the battery is full. |
+| `charging_symbol` | `""` | The symbol shown when the battery is charging. |
+| `discharging_symbol` | `""` | The symbol shown when the battery is discharging. |
+| `unknown_symbol` | `""` | The symbol shown when the battery state is unknown. |
+| `empty_symbol` | `""` | The symbol shown when the battery state is empty. |
+| `format` | `"[$symbol$percentage]($style) "` | The format for the module. |
+| `display` | [link](#battery-display) | Display threshold and style for the module. |
+| `disabled` | `false` | Disables the `battery` module. |
-<details>
-<summary>There are also options for some uncommon battery states.</summary>
-
-| Variable | Description |
-| ---------------- | --------------------------------------------------- |
-| `unknown_symbol` | The symbol shown when the battery state is unknown. |
-| `empty_symbol` | The symbol shown when the battery state is empty. |
-
-Note: Battery indicator will be hidden if the status is `unknown` or `empty` unless you specify the option in the config.
-
-</details>
### Example
diff --git a/docs/presets/README.md b/docs/presets/README.md
index e07d717e4..58f2b9425 100644
--- a/docs/presets/README.md
+++ b/docs/presets/README.md
@@ -20,11 +20,6 @@ If emojis aren't your thing, this might catch your eye!
[aws]
symbol = " "
-[battery]
-full_symbol = ""
-charging_symbol = ""
-discharging_symbol = ""
-
[conda]
symbol = " "
diff --git a/src/configs/battery.rs b/src/configs/battery.rs
index ec7287705..4349a25ce 100644
--- a/src/configs/battery.rs
+++ b/src/configs/battery.rs
@@ -7,8 +7,8 @@ pub struct BatteryConfig<'a> {
pub full_symbol: &'a str,
pub charging_symbol: &'a str,
pub discharging_symbol: &'a str,
- pub unknown_symbol: Option<&'a str>,
- pub empty_symbol: Option<&'a str>,
+ pub unknown_symbol: &'a str,
+ pub empty_symbol: &'a str,
pub display: Vec<BatteryDisplayConfig<'a>>,
pub disabled: bool,
pub format: &'a str,
@@ -17,11 +17,11 @@ pub struct BatteryConfig<'a> {
impl<'a> RootModuleConfig<'a> for BatteryConfig<'a> {
fn new() -> Self {
BatteryConfig {
- full_symbol: "•",
- charging_symbol: "↑",
- discharging_symbol: "↓",
- unknown_symbol: None,
- empty_symbol: None,
+ full_symbol: "",
+ charging_symbol: "",
+ discharging_symbol: "",
+ unknown_symbol: "",
+ empty_symbol: "",
format: "[$symbol$percentage]($style) ",
display: vec![BatteryDisplayConfig {
threshold: 10,
diff --git a/src/modules/battery.rs b/src/modules/battery.rs
index 2b773bf23..3f53573ac 100644
--- a/src/modules/battery.rs
+++ b/src/modules/battery.rs
@@ -35,8 +35,8 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
battery::State::Full => Some(config.full_symbol),
battery::State::Charging => Some(config.charging_symbol),
battery::State::Discharging => Some(config.discharging_symbol),
- battery::State::Unknown => config.unknown_symbol,
- battery::State::Empty => config.empty_symbol,
+ battery::State::Unknown => Some(config.unknown_symbol),
+ battery::State::Empty => Some(config.empty_symbol),
_ => {
log::debug!("Unhandled battery state `{}`", state);
None
@@ -85,7 +85,12 @@ fn get_battery_status() -> Option<BatteryStatus> {
})
}
Err(e) => {
- log::warn!("Unable to access battery information:\n{}", &e);
+ let level = if cfg!(target_os = "linux") {
+ log::Level::Info
+ } else {
+ log::Level::Warn
+ };
+ log::log!(level, "Unable to access battery information:\n{}", &e);
None
}
})