Waybar/include/modules/cpu_usage.hpp

33 lines
640 B
C++
Raw Normal View History

2022-12-21 16:47:06 +00:00
#pragma once
#include <fmt/format.h>
#include <cstdint>
#include <fstream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
2023-04-13 23:25:13 +00:00
#include "ALabel.hpp"
2022-12-21 16:47:06 +00:00
#include "util/sleeper_thread.hpp"
namespace waybar::modules {
2023-04-13 23:25:13 +00:00
class CpuUsage : public ALabel {
2022-12-21 16:47:06 +00:00
public:
CpuUsage(const std::string&, const Json::Value&);
~CpuUsage() = default;
auto update() -> void;
private:
std::tuple<std::vector<uint16_t>, std::string> getCpuUsage();
std::vector<std::tuple<size_t, size_t>> parseCpuinfo();
std::vector<std::tuple<size_t, size_t>> prev_times_;
util::SleeperThread thread_;
};
} // namespace waybar::modules