1
0
mirror of https://github.com/xmrig/xmrig.git synced 2025-12-10 17:12:46 -05:00

Added pause-on-active option

Windows only for now. When set to true, pauses mining when user touches mouse or keyboard.
This commit is contained in:
SChernykh
2021-02-14 15:32:18 +01:00
parent 8e3fec5768
commit 82830e359a
13 changed files with 57 additions and 6 deletions

View File

@@ -62,6 +62,7 @@ const char *BaseConfig::kDryRun = "dry-run";
const char *BaseConfig::kHttp = "http";
const char *BaseConfig::kLogFile = "log-file";
const char *BaseConfig::kPauseOnBattery = "pause-on-battery";
const char *BaseConfig::kPauseOnActive = "pause-on-active";
const char *BaseConfig::kPrintTime = "print-time";
const char *BaseConfig::kSyslog = "syslog";
const char *BaseConfig::kTitle = "title";
@@ -92,6 +93,7 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
m_syslog = reader.getBool(kSyslog, m_syslog);
m_watch = reader.getBool(kWatch, m_watch);
m_pauseOnBattery = reader.getBool(kPauseOnBattery, m_pauseOnBattery);
m_pauseOnActive = reader.getBool(kPauseOnActive, m_pauseOnActive);
m_logFile = reader.getString(kLogFile);
m_userAgent = reader.getString(kUserAgent);
m_printTime = std::min(reader.getUint(kPrintTime, m_printTime), 3600U);

View File

@@ -56,6 +56,7 @@ public:
static const char *kHttp;
static const char *kLogFile;
static const char *kPauseOnBattery;
static const char *kPauseOnActive;
static const char *kPrintTime;
static const char *kSyslog;
static const char *kTitle;
@@ -73,6 +74,7 @@ public:
inline bool isBackground() const { return m_background; }
inline bool isDryRun() const { return m_dryRun; }
inline bool isPauseOnBattery() const { return m_pauseOnBattery; }
inline bool isPauseOnActive() const { return m_pauseOnActive; }
inline bool isSyslog() const { return m_syslog; }
inline const char *logFile() const { return m_logFile.data(); }
inline const char *userAgent() const { return m_userAgent.data(); }
@@ -101,6 +103,7 @@ protected:
bool m_background = false;
bool m_dryRun = false;
bool m_pauseOnBattery = false;
bool m_pauseOnActive = false;
bool m_syslog = false;
bool m_upgrade = false;
bool m_watch = true;

View File

@@ -262,6 +262,7 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
case IConfig::DaemonKey: /* --daemon */
case IConfig::VerboseKey: /* --verbose */
case IConfig::PauseOnBatteryKey: /* --pause-on-battery */
case IConfig::PauseOnActiveKey: /* --pause-on-active */
return transformBoolean(doc, key, true);
case IConfig::ColorKey: /* --no-color */
@@ -323,6 +324,9 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b
case IConfig::PauseOnBatteryKey: /* --pause-on-battery */
return set(doc, BaseConfig::kPauseOnBattery, enable);
case IConfig::PauseOnActiveKey: /* --pause-on-active */
return set(doc, BaseConfig::kPauseOnActive, enable);
default:
break;
}