This commit is contained in:
Alik Aslanyan 2024-11-22 06:56:19 +00:00 committed by GitHub
commit 589e4c2b97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 9 deletions

View file

@ -180,15 +180,21 @@ else()
if (XMRIG_OS_ANDROID)
set(EXTRA_LIBS pthread rt dl log)
elseif (XMRIG_OS_LINUX)
list(APPEND SOURCES_OS
src/crypto/common/LinuxMemory.h
src/crypto/common/LinuxMemory.cpp
)
else()
if (XMRIG_OS_LINUX)
list(APPEND SOURCES_OS
src/crypto/common/LinuxMemory.h
src/crypto/common/LinuxMemory.cpp
)
set(EXTRA_LIBS pthread rt dl)
elseif (XMRIG_OS_FREEBSD)
set(EXTRA_LIBS kvm pthread)
set(EXTRA_LIBS pthread rt dl)
elseif (XMRIG_OS_FREEBSD)
set(EXTRA_LIBS kvm pthread)
endif()
find_package(X11 REQUIRED)
set(EXTRA_LIBS ${EXTRA_LIBS} Xss ${X11_LIBRARIES})
include_directories(${X11_INCLUDE_DIR})
endif()
endif()

View file

@ -38,6 +38,8 @@
#include <fstream>
#include <limits>
#include <X11/extensions/scrnsaver.h>
#include "base/kernel/Platform.h"
#include "version.h"
@ -175,5 +177,19 @@ bool xmrig::Platform::isOnBatteryPower()
uint64_t xmrig::Platform::idleTime()
{
return std::numeric_limits<uint64_t>::max();
Display *dpy = XOpenDisplay(nullptr);
if (!dpy) {
return std::numeric_limits<uint64_t>::max();
}
XScreenSaverInfo *info = XScreenSaverAllocInfo();
XScreenSaverQueryInfo(dpy, DefaultRootWindow(dpy), info);
uint64_t idle = info->idle;
XFree(info);
XCloseDisplay(dpy);
return idle;
}