diff --git a/CMakeLists.txt b/CMakeLists.txt index dfe92e85..78270e80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/base/kernel/Platform_mac.cpp b/src/base/kernel/Platform_mac.cpp index 9dd4f15e..8ffae1e1 100644 --- a/src/base/kernel/Platform_mac.cpp +++ b/src/base/kernel/Platform_mac.cpp @@ -22,6 +22,8 @@ */ +#include +#include #include #include #include @@ -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; }