feat(battery): add ramp-charging tag (#3172)

* feat(battery): add ramp-charging tag

* Update battery.cpp

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md
This commit is contained in:
clover 2024-10-19 11:34:47 -04:00 committed by GitHub
parent 15ccea6099
commit 2d00384046
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View File

@ -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))).

View File

@ -77,6 +77,7 @@ namespace modules {
static constexpr const char* TAG_ANIMATION_LOW{"<animation-low>"};
static constexpr const char* TAG_BAR_CAPACITY{"<bar-capacity>"};
static constexpr const char* TAG_RAMP_CAPACITY{"<ramp-capacity>"};
static constexpr const char* TAG_RAMP_CHARGING{"<ramp-charging>"};
static constexpr const char* TAG_LABEL_CHARGING{"<label-charging>"};
static constexpr const char* TAG_LABEL_DISCHARGING{"<label-discharging>"};
static constexpr const char* TAG_LABEL_FULL{"<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;

View File

@ -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) {