diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ef0a211..282333d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added - An option `unmute-on-scroll` for `internal/pulseaudio` and `internal/alsa` to unmute audio when the user scrolls on the widget. +- `internal/battery`: Added `ramp-charging` tag. +([`#3172`](https://github.com/polybar/polybar/pull/3172)) +by [@stringlapse](https://github.com/stringlapse). ### Changed - When the `-r` flag is provided, and RandR reports zero connected active screens, polybar will not restart. This fixes polybar dying on some laptops when the lid is closed. ([`#3078`](https://github.com/polybar/polybar/pull/3078))). diff --git a/include/modules/battery.hpp b/include/modules/battery.hpp index 0ee1fc31..52e29fd4 100644 --- a/include/modules/battery.hpp +++ b/include/modules/battery.hpp @@ -77,6 +77,7 @@ namespace modules { static constexpr const char* TAG_ANIMATION_LOW{""}; static constexpr const char* TAG_BAR_CAPACITY{""}; static constexpr const char* TAG_RAMP_CAPACITY{""}; + static constexpr const char* TAG_RAMP_CHARGING{""}; static constexpr const char* TAG_LABEL_CHARGING{""}; static constexpr const char* TAG_LABEL_DISCHARGING{""}; static constexpr const char* TAG_LABEL_FULL{""}; @@ -98,6 +99,7 @@ namespace modules { animation_t m_animation_low; progressbar_t m_bar_capacity; ramp_t m_ramp_capacity; + ramp_t m_ramp_charging; string m_fstate; string m_fcapnow; diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index 7d7ac379..f1ba3b17 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -114,7 +114,7 @@ namespace modules { // Add formats and elements m_formatter->add(FORMAT_CHARGING, TAG_LABEL_CHARGING, - {TAG_BAR_CAPACITY, TAG_RAMP_CAPACITY, TAG_ANIMATION_CHARGING, TAG_LABEL_CHARGING}); + {TAG_BAR_CAPACITY, TAG_RAMP_CAPACITY, TAG_RAMP_CHARGING, TAG_ANIMATION_CHARGING, TAG_LABEL_CHARGING}); m_formatter->add(FORMAT_DISCHARGING, TAG_LABEL_DISCHARGING, {TAG_BAR_CAPACITY, TAG_RAMP_CAPACITY, TAG_ANIMATION_DISCHARGING, TAG_LABEL_DISCHARGING}); m_formatter->add_optional(FORMAT_LOW, {TAG_BAR_CAPACITY, TAG_RAMP_CAPACITY, TAG_ANIMATION_LOW, TAG_LABEL_LOW}); @@ -135,6 +135,9 @@ namespace modules { if (m_formatter->has(TAG_RAMP_CAPACITY)) { m_ramp_capacity = load_ramp(m_conf, name(), TAG_RAMP_CAPACITY); } + if (m_formatter->has(TAG_RAMP_CHARGING)) { + m_ramp_charging = load_ramp(m_conf, name(), TAG_RAMP_CHARGING); + } if (m_formatter->has(TAG_LABEL_CHARGING, FORMAT_CHARGING)) { m_label_charging = load_optional_label(m_conf, name(), TAG_LABEL_CHARGING, "%percentage%%"); } @@ -285,6 +288,8 @@ namespace modules { builder->node(m_bar_capacity->output(clamp_percentage(m_percentage, m_state))); } else if (tag == TAG_RAMP_CAPACITY) { builder->node(m_ramp_capacity->get_by_percentage_with_borders(m_percentage, m_lowat, m_fullat)); + } else if (tag == TAG_RAMP_CHARGING) { + builder->node(m_ramp_charging->get_by_percentage_with_borders(m_percentage, m_lowat, m_fullat)); } else if (tag == TAG_LABEL_CHARGING) { builder->node(m_label_charging); } else if (tag == TAG_LABEL_DISCHARGING) {