mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-08 08:23:34 -05:00
Added idle time detection for macOS.
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
#include <uv.h>
|
||||
#include <thread>
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
|
||||
|
||||
#include "base/kernel/Platform.h"
|
||||
@@ -112,5 +111,14 @@ bool xmrig::Platform::isOnBatteryPower()
|
||||
|
||||
uint64_t xmrig::Platform::idleTime()
|
||||
{
|
||||
return std::numeric_limits<uint64_t>::max();
|
||||
uint64_t idle_time = 0;
|
||||
const auto service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOHIDSystem"));
|
||||
const auto property = IORegistryEntryCreateCFProperty(service, CFSTR("HIDIdleTime"), kCFAllocatorDefault, 0);
|
||||
|
||||
CFNumberGetValue((CFNumberRef)property, kCFNumberSInt64Type, &idle_time);
|
||||
|
||||
CFRelease(property);
|
||||
IOObjectRelease(service);
|
||||
|
||||
return idle_time / 1000000U;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user