Introduce cpu_usage module

This commit is contained in:
Mann mit Hut
2022-12-21 17:47:06 +01:00
parent c36fe3a004
commit 888adb57ec
7 changed files with 251 additions and 0 deletions

View File

@ -39,6 +39,7 @@
#if defined(HAVE_CPU_LINUX) || defined(HAVE_CPU_BSD)
#include "modules/cpu.hpp"
#include "modules/cpu_frequency.hpp"
#include "modules/cpu_usage.hpp"
#include "modules/load.hpp"
#endif
#include "modules/idle_inhibitor.hpp"

View File

@ -0,0 +1,32 @@
#pragma once
#include <fmt/format.h>
#include <cstdint>
#include <fstream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#include "AButton.hpp"
#include "util/sleeper_thread.hpp"
namespace waybar::modules {
class CpuUsage : public AButton {
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