waybar/include/modules/battery.hpp
2018-08-13 22:33:07 +02:00

32 lines
697 B
C++

#pragma once
#include <json/json.h>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <fmt/format.h>
#include <sys/inotify.h>
#include <algorithm>
#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;
};
}