Added mining on battery setting
This commit is contained in:
parent
5bc89fdc8b
commit
299b180b28
10 changed files with 95 additions and 18 deletions
|
@ -38,6 +38,7 @@
|
|||
#include <unistd.h>
|
||||
#include <uv.h>
|
||||
#include <thread>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
#include "base/kernel/Platform.h"
|
||||
|
@ -146,3 +147,19 @@ void xmrig::Platform::setThreadPriority(int priority)
|
|||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Platform::isOnBatteryPower()
|
||||
{
|
||||
for (int i = 0; i <= 1; ++i) {
|
||||
char buf[64];
|
||||
snprintf(buf, 64, "/sys/class/power_supply/BAT%d/status", i);
|
||||
std::ifstream f(buf);
|
||||
if (f.is_open()) {
|
||||
std::string status;
|
||||
f >> status;
|
||||
return (status == "Discharging");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue