added support for battery state-based classes on the entire waybar

This commit is contained in:
ArneshRC
2024-01-07 17:09:31 +05:30
parent 4b20f522f0
commit 3390c16f52
3 changed files with 42 additions and 4 deletions

View File

@ -16,6 +16,7 @@
#include <vector>
#include "ALabel.hpp"
#include "bar.hpp"
#include "util/sleeper_thread.hpp"
namespace waybar::modules {
@ -28,7 +29,7 @@ namespace fs = std::filesystem;
class Battery : public ALabel {
public:
Battery(const std::string&, const Json::Value&);
Battery(const std::string&, const waybar::Bar&, const Json::Value&);
virtual ~Battery();
auto update() -> void override;
@ -40,6 +41,7 @@ class Battery : public ALabel {
const std::string getAdapterStatus(uint8_t capacity) const;
const std::tuple<uint8_t, float, std::string, float> getInfos();
const std::string formatTimeRemaining(float hoursRemaining);
void setBarClass(std::string&);
int global_watch;
std::map<fs::path, int> batteries_;
@ -49,6 +51,7 @@ class Battery : public ALabel {
std::mutex battery_list_mutex_;
std::string old_status_;
bool warnFirstTime_{true};
const Bar& bar_;
util::SleeperThread thread_;
util::SleeperThread thread_battery_update_;