mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-11 17:32:47 -05:00
Implement pause-on-active for Linux and FreeBSD
This commit is contained in:
@@ -36,6 +36,8 @@
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
|
||||
#include <X11/extensions/scrnsaver.h>
|
||||
|
||||
|
||||
#include "base/kernel/Platform.h"
|
||||
#include "version.h"
|
||||
@@ -163,5 +165,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user