fix(Battery) "current" unused and removed
This commit is contained in:
parent
3e76984ce7
commit
2db81a6107
|
@ -33,8 +33,8 @@ class Battery : public ALabel {
|
||||||
|
|
||||||
void getBatteries();
|
void getBatteries();
|
||||||
void worker();
|
void worker();
|
||||||
const std::string getAdapterStatus(uint8_t capacity, uint32_t current_now) const;
|
const std::string getAdapterStatus(uint8_t capacity) const;
|
||||||
const std::tuple<uint8_t, uint32_t, std::string> getInfos() const;
|
const std::tuple<uint8_t, std::string> getInfos() const;
|
||||||
|
|
||||||
util::SleeperThread thread_;
|
util::SleeperThread thread_;
|
||||||
util::SleeperThread thread_timer_;
|
util::SleeperThread thread_timer_;
|
||||||
|
|
|
@ -76,23 +76,19 @@ void waybar::modules::Battery::getBatteries() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::tuple<uint8_t, uint32_t, std::string> waybar::modules::Battery::getInfos() const {
|
const std::tuple<uint8_t, std::string> waybar::modules::Battery::getInfos() const {
|
||||||
try {
|
try {
|
||||||
uint16_t total = 0;
|
uint16_t total = 0;
|
||||||
uint32_t total_current = 0;
|
|
||||||
std::string status = "Unknown";
|
std::string status = "Unknown";
|
||||||
for (auto const& bat : batteries_) {
|
for (auto const& bat : batteries_) {
|
||||||
uint16_t capacity;
|
uint16_t capacity;
|
||||||
uint32_t current_now;
|
|
||||||
std::string _status;
|
std::string _status;
|
||||||
std::ifstream(bat / "capacity") >> capacity;
|
std::ifstream(bat / "capacity") >> capacity;
|
||||||
std::ifstream(bat / "status") >> _status;
|
std::ifstream(bat / "status") >> _status;
|
||||||
std::ifstream(bat / "current_now") >> current_now;
|
|
||||||
if (_status != "Unknown") {
|
if (_status != "Unknown") {
|
||||||
status = _status;
|
status = _status;
|
||||||
}
|
}
|
||||||
total += capacity;
|
total += capacity;
|
||||||
total_current += current_now;
|
|
||||||
}
|
}
|
||||||
if (!adapter_.empty() && status == "Discharging") {
|
if (!adapter_.empty() && status == "Discharging") {
|
||||||
bool online;
|
bool online;
|
||||||
|
@ -102,15 +98,14 @@ const std::tuple<uint8_t, uint32_t, std::string> waybar::modules::Battery::getIn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint16_t capacity = total / batteries_.size();
|
uint16_t capacity = total / batteries_.size();
|
||||||
return {capacity, total_current, status};
|
return {capacity, status};
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
spdlog::error("Battery: {}", e.what());
|
spdlog::error("Battery: {}", e.what());
|
||||||
return {0, 0, "Unknown"};
|
return {0, "Unknown"};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string waybar::modules::Battery::getAdapterStatus(uint8_t capacity,
|
const std::string waybar::modules::Battery::getAdapterStatus(uint8_t capacity) const {
|
||||||
uint32_t current_now) const {
|
|
||||||
if (!adapter_.empty()) {
|
if (!adapter_.empty()) {
|
||||||
bool online;
|
bool online;
|
||||||
std::ifstream(adapter_ / "online") >> online;
|
std::ifstream(adapter_ / "online") >> online;
|
||||||
|
@ -126,9 +121,9 @@ const std::string waybar::modules::Battery::getAdapterStatus(uint8_t capacity,
|
||||||
}
|
}
|
||||||
|
|
||||||
auto waybar::modules::Battery::update() -> void {
|
auto waybar::modules::Battery::update() -> void {
|
||||||
auto [capacity, current_now, status] = getInfos();
|
auto [capacity, status] = getInfos();
|
||||||
if (status == "Unknown") {
|
if (status == "Unknown") {
|
||||||
status = getAdapterStatus(capacity, current_now);
|
status = getAdapterStatus(capacity);
|
||||||
}
|
}
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(status);
|
label_.set_tooltip_text(status);
|
||||||
|
|
Loading…
Reference in New Issue