Merge branch 'master' into master

pull/1002/head
nullobsi 2021-03-14 21:34:25 -07:00 committed by GitHub
commit bf3efdb89c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -1,7 +1,6 @@
#pragma once
#include <fmt/format.h>
#include <unistd.h>
#include <cstdint>
#include <fstream>
#include <numeric>
@ -20,7 +19,7 @@ class Cpu : public ALabel {
auto update() -> void;
private:
uint16_t getCpuLoad();
double getCpuLoad();
std::tuple<uint16_t, std::string> getCpuUsage();
std::vector<std::tuple<size_t, size_t>> parseCpuinfo();

View File

@ -32,10 +32,10 @@ auto waybar::modules::Cpu::update() -> void {
ALabel::update();
}
uint16_t waybar::modules::Cpu::getCpuLoad() {
double waybar::modules::Cpu::getCpuLoad() {
double load[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");
}