mirror of
https://github.com/xmrig/xmrig.git
synced 2024-10-29 20:47:50 +00:00
Merge branch 'battery-macos' of https://github.com/jtgrassie/xmrig into dev
This commit is contained in:
commit
f06e30e343
2 changed files with 5 additions and 11 deletions
|
@ -143,6 +143,8 @@ elseif (XMRIG_OS_APPLE)
|
|||
src/App_unix.cpp
|
||||
src/crypto/common/VirtualMemory_unix.cpp
|
||||
)
|
||||
find_library(IOKIT_LIBRARY IOKit)
|
||||
set(EXTRA_LIBS ${IOKIT_LIBRARY})
|
||||
else()
|
||||
list(APPEND SOURCES_OS
|
||||
src/App_unix.cpp
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#include <IOKit/ps/IOPowerSources.h>
|
||||
#include <mach/thread_act.h>
|
||||
#include <mach/thread_policy.h>
|
||||
#include <stdio.h>
|
||||
|
@ -111,15 +113,5 @@ void xmrig::Platform::setThreadPriority(int priority)
|
|||
|
||||
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;
|
||||
return IOPSGetTimeRemainingEstimate() != kIOPSTimeRemainingUnlimited;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue