2016-05-31 05:58:58 +02:00
|
|
|
#pragma once
|
2016-05-19 16:41:06 +02:00
|
|
|
|
2016-11-20 23:04:31 +01:00
|
|
|
#include "modules/meta/timer_module.hpp"
|
2020-05-15 19:59:08 +02:00
|
|
|
#include "settings.hpp"
|
2016-05-19 16:41:06 +02:00
|
|
|
|
2016-11-19 06:22:44 +01:00
|
|
|
POLYBAR_NS
|
2016-06-15 05:32:35 +02:00
|
|
|
|
|
|
|
namespace modules {
|
|
|
|
struct cpu_time {
|
2016-05-19 16:41:06 +02:00
|
|
|
unsigned long long user;
|
|
|
|
unsigned long long nice;
|
|
|
|
unsigned long long system;
|
|
|
|
unsigned long long idle;
|
2019-12-16 11:05:18 -05:00
|
|
|
unsigned long long steal;
|
2016-05-19 16:41:06 +02:00
|
|
|
unsigned long long total;
|
|
|
|
};
|
|
|
|
|
2016-06-15 05:32:35 +02:00
|
|
|
using cpu_time_t = unique_ptr<cpu_time>;
|
|
|
|
|
|
|
|
class cpu_module : public timer_module<cpu_module> {
|
|
|
|
public:
|
2016-12-21 08:00:09 +01:00
|
|
|
explicit cpu_module(const bar_settings&, string);
|
2016-06-15 05:32:35 +02:00
|
|
|
|
2016-11-02 20:22:45 +01:00
|
|
|
bool update();
|
2016-11-25 13:55:15 +01:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-06-15 05:32:35 +02:00
|
|
|
|
2020-05-15 19:59:08 +02:00
|
|
|
static constexpr auto TYPE = "internal/cpu";
|
|
|
|
|
2016-06-15 05:32:35 +02:00
|
|
|
protected:
|
2016-11-02 20:22:45 +01:00
|
|
|
bool read_values();
|
|
|
|
float get_load(size_t core) const;
|
2016-06-15 05:32:35 +02:00
|
|
|
|
|
|
|
private:
|
2016-05-31 05:58:58 +02:00
|
|
|
static constexpr auto TAG_LABEL = "<label>";
|
2016-05-26 02:14:56 +02:00
|
|
|
static constexpr auto TAG_BAR_LOAD = "<bar-load>";
|
|
|
|
static constexpr auto TAG_RAMP_LOAD = "<ramp-load>";
|
2016-10-12 05:19:29 +02:00
|
|
|
static constexpr auto TAG_RAMP_LOAD_PER_CORE = "<ramp-coreload>";
|
2016-05-19 16:41:06 +02:00
|
|
|
|
2016-06-15 05:32:35 +02:00
|
|
|
progressbar_t m_barload;
|
|
|
|
ramp_t m_rampload;
|
|
|
|
ramp_t m_rampload_core;
|
|
|
|
label_t m_label;
|
2018-10-16 01:11:05 +02:00
|
|
|
int m_ramp_padding;
|
2016-05-19 16:41:06 +02:00
|
|
|
|
2016-06-15 05:32:35 +02:00
|
|
|
vector<cpu_time_t> m_cputimes;
|
|
|
|
vector<cpu_time_t> m_cputimes_prev;
|
2016-05-19 16:41:06 +02:00
|
|
|
|
2016-06-15 05:32:35 +02:00
|
|
|
float m_total = 0;
|
|
|
|
vector<float> m_load;
|
2016-05-19 16:41:06 +02:00
|
|
|
};
|
2020-05-15 19:59:08 +02:00
|
|
|
} // namespace modules
|
2016-06-15 05:32:35 +02:00
|
|
|
|
2016-11-19 06:22:44 +01:00
|
|
|
POLYBAR_NS_END
|