Add mine-when-idle, default banlist, and console parsing improvements
Mine-when-idle: - Auto-start/stop mining based on system idle time detection - Platform::getSystemIdleSeconds() via XScreenSaver (Linux) / GetLastInputInfo (Win) - Settings: mine_when_idle toggle + configurable delay (30s–10m) - Settings page UI with checkbox and delay combo Console tab: - Shell-like argument parsing with quote and JSON bracket support - Pass JSON objects/arrays directly as RPC params - Fix selection indices when lines are evicted from buffer Connection & status bar: - Reduce RPC connect timeout to 1s for localhost fast-fail - Fast retry timer on daemon startup and external daemon detection - Show pool mining hashrate in status bar; sidebar badge reflects pool state UI polish: - Add logo to About card in settings; expose logo dimensions on App - Header title offset-y support; adjust content-area margins - Fix banned peers row cursor position (rawRowPosB.x) Branding: - Update copyright to "DragonX Developers" in RC and About section - Replace logo/icon assets with updated versions Misc: - setup.sh: checkout dragonx branch before pulling - Remove stale prebuilt-binaries/xmrig/.gitkeep
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <dirent.h>
|
||||
#include <dlfcn.h>
|
||||
#ifdef __APPLE__
|
||||
#include <mach-o/dyld.h>
|
||||
#include <sys/sysctl.h>
|
||||
@@ -596,5 +597,94 @@ double Platform::getDaemonMemoryUsageMB()
|
||||
#endif
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// System-wide idle time detection
|
||||
// ============================================================================
|
||||
|
||||
int Platform::getSystemIdleSeconds()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LASTINPUTINFO lii;
|
||||
lii.cbSize = sizeof(lii);
|
||||
if (GetLastInputInfo(&lii)) {
|
||||
DWORD elapsed = GetTickCount() - lii.dwTime;
|
||||
return (int)(elapsed / 1000);
|
||||
}
|
||||
return 0;
|
||||
#elif defined(__APPLE__)
|
||||
// macOS: use IOKit HIDSystem idle time
|
||||
// Fallback to 0 (feature not supported) to keep it simple
|
||||
return 0;
|
||||
#else
|
||||
// Linux: dynamically load libXss to query X11 screensaver idle time
|
||||
// This avoids a hard link dependency on X11/Xss libraries.
|
||||
typedef struct {
|
||||
int type;
|
||||
unsigned long serial;
|
||||
int/*Bool*/ send_event;
|
||||
void* /*Display**/ display;
|
||||
unsigned long/*Drawable*/ window;
|
||||
int state;
|
||||
int kind;
|
||||
unsigned long til_or_since;
|
||||
unsigned long idle;
|
||||
unsigned long eventMask;
|
||||
} XScreenSaverInfo;
|
||||
|
||||
// Function pointer types
|
||||
typedef void* (*XOpenDisplay_t)(const char*);
|
||||
typedef unsigned long (*XDefaultRootWindow_t)(void*);
|
||||
typedef XScreenSaverInfo* (*XScreenSaverAllocInfo_t)(void);
|
||||
typedef int (*XScreenSaverQueryInfo_t)(void*, unsigned long, XScreenSaverInfo*);
|
||||
typedef int (*XCloseDisplay_t)(void*);
|
||||
typedef void (*XFree_t)(void*);
|
||||
|
||||
static bool s_tried = false;
|
||||
static void* s_x11 = nullptr;
|
||||
static void* s_xss = nullptr;
|
||||
static XOpenDisplay_t s_XOpenDisplay = nullptr;
|
||||
static XDefaultRootWindow_t s_XDefaultRootWindow = nullptr;
|
||||
static XScreenSaverAllocInfo_t s_XScreenSaverAllocInfo = nullptr;
|
||||
static XScreenSaverQueryInfo_t s_XScreenSaverQueryInfo = nullptr;
|
||||
static XCloseDisplay_t s_XCloseDisplay = nullptr;
|
||||
(void)s_XCloseDisplay; // retained for potential cleanup
|
||||
static XFree_t s_XFree = nullptr;
|
||||
static void* s_display = nullptr;
|
||||
|
||||
if (!s_tried) {
|
||||
s_tried = true;
|
||||
s_x11 = dlopen("libX11.so.6", RTLD_LAZY);
|
||||
s_xss = dlopen("libXss.so.1", RTLD_LAZY);
|
||||
if (s_x11 && s_xss) {
|
||||
s_XOpenDisplay = (XOpenDisplay_t)dlsym(s_x11, "XOpenDisplay");
|
||||
s_XDefaultRootWindow = (XDefaultRootWindow_t)dlsym(s_x11, "XDefaultRootWindow");
|
||||
s_XCloseDisplay = (XCloseDisplay_t)dlsym(s_x11, "XCloseDisplay"); // NOLINT
|
||||
s_XFree = (XFree_t)dlsym(s_x11, "XFree");
|
||||
s_XScreenSaverAllocInfo = (XScreenSaverAllocInfo_t)dlsym(s_xss, "XScreenSaverAllocInfo");
|
||||
s_XScreenSaverQueryInfo = (XScreenSaverQueryInfo_t)dlsym(s_xss, "XScreenSaverQueryInfo");
|
||||
|
||||
if (s_XOpenDisplay && s_XDefaultRootWindow && s_XScreenSaverAllocInfo && s_XScreenSaverQueryInfo) {
|
||||
s_display = s_XOpenDisplay(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!s_display || !s_XScreenSaverAllocInfo || !s_XScreenSaverQueryInfo || !s_XDefaultRootWindow) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
XScreenSaverInfo* info = s_XScreenSaverAllocInfo();
|
||||
if (!info) return 0;
|
||||
|
||||
int idleSec = 0;
|
||||
unsigned long root = s_XDefaultRootWindow(s_display);
|
||||
if (s_XScreenSaverQueryInfo(s_display, root, info)) {
|
||||
idleSec = (int)(info->idle / 1000); // idle is in milliseconds
|
||||
}
|
||||
if (s_XFree) s_XFree(info);
|
||||
return idleSec;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace dragonx
|
||||
|
||||
@@ -123,6 +123,14 @@ public:
|
||||
* @return Combined daemon RSS in MB, or 0 if no daemon found
|
||||
*/
|
||||
static double getDaemonMemoryUsageMB();
|
||||
|
||||
/**
|
||||
* @brief Get system-wide idle time in seconds
|
||||
* Uses platform-specific APIs: GetLastInputInfo (Windows),
|
||||
* XScreenSaverQueryInfo via dlopen (Linux), IOKit (macOS).
|
||||
* @return Seconds since last user input, or 0 on failure
|
||||
*/
|
||||
static int getSystemIdleSeconds();
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user