From 9c57df505c4401ce42dc205d07049715ca6aa79d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20L=2E=20Treffenst=C3=A4dt?= Date: Fri, 2 Nov 2018 19:41:00 +0100 Subject: [PATCH] Add class for full battery and give option to interpret unknown as full --- src/modules/battery.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index 70892fa..3b1ebb8 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -74,6 +74,8 @@ std::tuple waybar::modules::Battery::getInfos() std::ifstream(bat / "status") >> _status; if (_status != "Unknown") { status = _status; + }else if (config_["full-is-unknown"].isString() && config_["full-is-unknown"] == "true") { + status = "Full"; //Some notebooks (e.g. Thinkpad T430s) report a full battery as "Unknown". } total += capacity; } @@ -125,8 +127,13 @@ auto waybar::modules::Battery::update() -> void } } else { label_.get_style_context()->remove_class("charging"); - if (status == "Full" && config_["format-full"].isString()) { - format = config_["format-full"].asString(); + if (status == "Full"){ + label_.get_style_context()->add_class("full"); + if (config_["format-full"].isString()) { + format = config_["format-full"].asString(); + } + }else{ + label_.get_style_context()->remove_class("full"); } } auto state = getState(capacity, charging);