Waybar/include/modules/battery.hpp

31 lines
676 B
C++

#pragma once
#include <json/json.h>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <fmt/format.h>
#include <sys/inotify.h>
#include "util/chrono.hpp"
#include "IModule.hpp"
namespace waybar::modules {
namespace fs = std::filesystem;
class Battery : public IModule {
public:
Battery(Json::Value config);
auto update() -> void;
operator Gtk::Widget&();
private:
std::string _getIcon(uint16_t percentage);
static inline const fs::path _data_dir = "/sys/class/power_supply/";
std::vector<fs::path> _batteries;
util::SleeperThread _thread;
Gtk::Label _label;
Json::Value _config;
};
}