Merge branch 'aristocratos:main' into main

This commit is contained in:
Jos Dehaes 2021-10-01 17:05:26 +02:00 committed by GitHub
commit 7bfbd83a47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 4 deletions

View file

@ -7,7 +7,7 @@
![Linux](https://img.shields.io/badge/-Linux-grey?logo=linux) ![Linux](https://img.shields.io/badge/-Linux-grey?logo=linux)
![Usage](https://img.shields.io/badge/Usage-System%20resource%20monitor-yellow) ![Usage](https://img.shields.io/badge/Usage-System%20resource%20monitor-yellow)
![c++20](https://img.shields.io/badge/cpp-c%2B%2B20-green) ![c++20](https://img.shields.io/badge/cpp-c%2B%2B20-green)
![btop_version](https://img.shields.io/github/v/tag/aristocratos/btop?label=version) ![latest_release](https://img.shields.io/github/v/tag/aristocratos/btop?label=release)
[![Donate](https://img.shields.io/badge/-Donate-yellow?logo=paypal)](https://paypal.me/aristocratos) [![Donate](https://img.shields.io/badge/-Donate-yellow?logo=paypal)](https://paypal.me/aristocratos)
[![Sponsor](https://img.shields.io/badge/-Sponsor-red?logo=github)](https://github.com/sponsors/aristocratos) [![Sponsor](https://img.shields.io/badge/-Sponsor-red?logo=github)](https://github.com/sponsors/aristocratos)
[![Coffee](https://img.shields.io/badge/-Buy%20me%20a%20Coffee-grey?logo=Ko-fi)](https://ko-fi.com/aristocratos) [![Coffee](https://img.shields.io/badge/-Buy%20me%20a%20Coffee-grey?logo=Ko-fi)](https://ko-fi.com/aristocratos)
@ -124,6 +124,7 @@ Also needs a UTF8 locale and a font that covers:
* Unicode Block “Braille Patterns” U+2800 - U+28FF (Not needed in TTY mode or with graphs set to type: block or tty.) * Unicode Block “Braille Patterns” U+2800 - U+28FF (Not needed in TTY mode or with graphs set to type: block or tty.)
* Unicode Block “Geometric Shapes” U+25A0 - U+25FF * Unicode Block “Geometric Shapes” U+25A0 - U+25FF
* Unicode Block "Box Drawing" and "Block Elements" U+2500 - U+259F * Unicode Block "Box Drawing" and "Block Elements" U+2500 - U+259F
* Unicode Block "General punctuation" U+2005
### **Notice (Text rendering issues)** ### **Notice (Text rendering issues)**

View file

@ -55,7 +55,7 @@ namespace Global {
{"#801414", "██████╔╝ ██║ ╚██████╔╝██║ ╚═╝ ╚═╝"}, {"#801414", "██████╔╝ ██║ ╚██████╔╝██║ ╚═╝ ╚═╝"},
{"#000000", "╚═════╝ ╚═╝ ╚═════╝ ╚═╝"}, {"#000000", "╚═════╝ ╚═╝ ╚═════╝ ╚═╝"},
}; };
const string Version = "1.0.11"; const string Version = "1.0.12";
int coreCount; int coreCount;
string overlay; string overlay;

View file

@ -1418,6 +1418,7 @@ namespace Proc {
else if (p.cpu_p >= 10'000) { else if (p.cpu_p >= 10'000) {
cpu_str = to_string(p.cpu_p / 1000); cpu_str = to_string(p.cpu_p / 1000);
cpu_str.resize(3); cpu_str.resize(3);
if (cpu_str.ends_with('.')) cpu_str.pop_back();
cpu_str += "k"; cpu_str += "k";
} }
string mem_str = (mem_bytes ? floating_humanizer(p.mem, true) : ""); string mem_str = (mem_bytes ? floating_humanizer(p.mem, true) : "");

View file

@ -339,7 +339,8 @@ namespace Tools {
for (string readstr; getline(file, readstr); out += readstr); for (string readstr; getline(file, readstr); out += readstr);
} }
catch (const std::exception& e) { catch (const std::exception& e) {
throw std::runtime_error("readfile() : Exception when reading " + (string)path + " : " + e.what()); Logger::error("readfile() : Exception when reading " + (string)path + " : " + e.what());
return fallback;
} }
return (out.empty() ? fallback : out); return (out.empty() ? fallback : out);
} }

View file

@ -1007,7 +1007,10 @@ namespace Net {
auto& saved_stat = net.at(iface).stat.at(dir); auto& saved_stat = net.at(iface).stat.at(dir);
auto& bandwidth = net.at(iface).bandwidth.at(dir); auto& bandwidth = net.at(iface).bandwidth.at(dir);
const uint64_t val = max((uint64_t)stoul(readfile(sys_file, "0")), saved_stat.last); uint64_t val = saved_stat.last;
try { val = max((uint64_t)stoul(readfile(sys_file, "0")), val); }
catch (const std::invalid_argument&) {}
catch (const std::out_of_range&) {}
//? Update speed, total and top values //? Update speed, total and top values
saved_stat.speed = round((double)(val - saved_stat.last) / ((double)(new_timestamp - timestamp) / 1000)); saved_stat.speed = round((double)(val - saved_stat.last) / ((double)(new_timestamp - timestamp) / 1000));