1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00
polybar/include/modules/cpu.hpp

56 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
2016-05-19 10:41:06 -04:00
2016-06-14 23:32:35 -04:00
#include <istream>
2016-05-19 10:41:06 -04:00
2016-06-14 23:32:35 -04:00
#include "config.hpp"
2016-05-19 10:41:06 -04:00
#include "drawtypes/label.hpp"
2016-06-14 23:32:35 -04:00
#include "drawtypes/progressbar.hpp"
2016-05-19 10:41:06 -04:00
#include "drawtypes/ramp.hpp"
2016-06-14 23:32:35 -04:00
#include "modules/meta.hpp"
2016-05-19 10:41:06 -04:00
2016-06-14 23:32:35 -04:00
LEMONBUDDY_NS
namespace modules {
struct cpu_time {
2016-05-19 10:41:06 -04:00
unsigned long long user;
unsigned long long nice;
unsigned long long system;
unsigned long long idle;
unsigned long long total;
};
2016-06-14 23:32:35 -04:00
using cpu_time_t = unique_ptr<cpu_time>;
class cpu_module : public timer_module<cpu_module> {
public:
using timer_module::timer_module;
2016-11-02 15:22:45 -04:00
void setup();
bool update();
bool build(builder* builder, string tag) const;
2016-06-14 23:32:35 -04:00
protected:
2016-11-02 15:22:45 -04:00
bool read_values();
float get_load(size_t core) const;
2016-06-14 23:32:35 -04:00
private:
static constexpr auto TAG_LABEL = "<label>";
static constexpr auto TAG_BAR_LOAD = "<bar-load>";
static constexpr auto TAG_RAMP_LOAD = "<ramp-load>";
static constexpr auto TAG_RAMP_LOAD_PER_CORE = "<ramp-coreload>";
2016-05-19 10:41:06 -04:00
2016-06-14 23:32:35 -04:00
progressbar_t m_barload;
ramp_t m_rampload;
ramp_t m_rampload_core;
label_t m_label;
2016-05-19 10:41:06 -04:00
2016-06-14 23:32:35 -04:00
vector<cpu_time_t> m_cputimes;
vector<cpu_time_t> m_cputimes_prev;
2016-05-19 10:41:06 -04:00
2016-06-14 23:32:35 -04:00
float m_total = 0;
vector<float> m_load;
2016-05-19 10:41:06 -04:00
};
}
2016-06-14 23:32:35 -04:00
LEMONBUDDY_NS_END