Waybar/include/modules/battery.hpp

33 lines
610 B
C++

#pragma once
#include <filesystem>
#include <fstream>
#include <iostream>
#include <fmt/format.h>
#include <sys/inotify.h>
#include <algorithm>
#include "util/chrono.hpp"
#include "ALabel.hpp"
namespace waybar::modules {
namespace fs = std::filesystem;
class Battery : public ALabel {
public:
Battery(const Json::Value&);
~Battery();
auto update() -> void;
private:
static inline const fs::path data_dir_ = "/sys/class/power_supply/";
void worker();
util::SleeperThread thread_;
util::SleeperThread threadTimer_;
std::vector<fs::path> batteries_;
int fd_;
};
}