diff --git a/index.html b/index.html
index 84d7a60..37dfc70 100644
--- a/index.html
+++ b/index.html
@@ -74,6 +74,16 @@
Minimize to tray:
+ Re-apply ryzenadj periodically:
+ Ryzen Controller will re-apply ryzenadj every X seconds. Set to 0 to disable.
+
Ryzenadj path:
diff --git a/js/app.js b/js/app.js
index 1049519..6edfe9e 100644
--- a/js/app.js
+++ b/js/app.js
@@ -1,10 +1,13 @@
ready(function(){
+ document.isStarting = true;
registerRepeaterForAllInput();
registerEventListenerForSettingsInput();
checkForAdminRights();
preFillSettings();
loadLatestUsedSettings();
displayVersion();
+ reApplyPeriodically(require('electron-settings').get('settings.reapply_periodically'));
+ document.isStarting = false;
});
/**
diff --git a/js/methods.js b/js/methods.js
index 46aeb74..7cc0c70 100644
--- a/js/methods.js
+++ b/js/methods.js
@@ -118,6 +118,8 @@ function preFillSettings() {
const settings = require('electron-settings');
document.getElementById('apply_last_settings_on_launch').checked = settings.get('settings.apply_last_settings_on_launch');
document.getElementById('minimize_to_tray').checked = settings.get('settings.minimize_to_tray');
+ document.getElementById('reapply_periodically').value = settings.get('settings.reapply_periodically');
+ document.getElementById('reapply_periodically_range').value = settings.get('settings.reapply_periodically');
}
/**
@@ -215,6 +217,14 @@ function registerEventListenerForSettingsInput() {
minimize_to_tray: !!minimize_to_tray.checked
});
});
+ var reapply_periodically = document.getElementById('reapply_periodically');
+ reapply_periodically.addEventListener('change', function() {
+ reApplyPeriodically(reapply_periodically.value);
+ settings.set('settings', {
+ ...settings.get('settings'),
+ reapply_periodically: reapply_periodically.value
+ });
+ });
}
/**
@@ -224,3 +234,23 @@ function displayVersion() {
const pjson = require('./package.json');
document.getElementById('version').innerHTML = `v${pjson.version}`;
}
+
+/**
+ * Re-apply flow for "reapply_periodically" settings.
+ * @param {number} seconds Interval in seconds between each apply.
+ */
+function reApplyPeriodically(seconds) {
+ appendLog(`reApplyPeriodically(): seconds = ${seconds}`);
+ appendLog(`reApplyPeriodically(): document.reapplyLoop = ${document.reapplyLoop}`);
+ clearInterval(document.reapplyLoop);
+ document.reapplyLoop = false;
+
+ if (seconds <= 0) {
+ if (!document.isStarting) {
+ notification('primary', "Ryzen Controller no more will re-apply ryzenadj periodically.");
+ }
+ return;
+ }
+
+ document.reapplyLoop = setInterval(applyRyzenSettings, seconds * 1000);
+}