mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge pull request #1050 from cmovcc/cmovcc/load-values
Fix: CPU load values
This commit is contained in:
commit
b4ffb8af45
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
@ -20,7 +19,7 @@ class Cpu : public ALabel {
|
|||||||
auto update() -> void;
|
auto update() -> void;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint16_t getCpuLoad();
|
double getCpuLoad();
|
||||||
std::tuple<uint16_t, std::string> getCpuUsage();
|
std::tuple<uint16_t, std::string> getCpuUsage();
|
||||||
std::vector<std::tuple<size_t, size_t>> parseCpuinfo();
|
std::vector<std::tuple<size_t, size_t>> parseCpuinfo();
|
||||||
|
|
||||||
|
@ -32,10 +32,10 @@ auto waybar::modules::Cpu::update() -> void {
|
|||||||
ALabel::update();
|
ALabel::update();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t waybar::modules::Cpu::getCpuLoad() {
|
double waybar::modules::Cpu::getCpuLoad() {
|
||||||
double load[1];
|
double load[1];
|
||||||
if (getloadavg(load, 1) != -1) {
|
if (getloadavg(load, 1) != -1) {
|
||||||
return load[0] * 100 / sysconf(_SC_NPROCESSORS_ONLN);
|
return load[0];
|
||||||
}
|
}
|
||||||
throw std::runtime_error("Can't get Cpu load");
|
throw std::runtime_error("Can't get Cpu load");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user