mirror of
https://github.com/rad4day/Waybar.git
synced 2025-07-13 22:52:30 +02:00
Introduce cpu_usage module
This commit is contained in:
@ -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"
|
||||
|
32
include/modules/cpu_usage.hpp
Normal file
32
include/modules/cpu_usage.hpp
Normal 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
|
Reference in New Issue
Block a user