Fix #1 Added periodically reapply ryzenadj capability.

This commit is contained in:
Quentin Decaunes 2019-03-01 17:12:05 +01:00
parent 4c1451ae71
commit a8897fba00
3 changed files with 43 additions and 0 deletions

View File

@ -74,6 +74,16 @@
<label><input class="uk-checkbox" type="checkbox" id="apply_last_settings_on_launch"> When checked, Ryzen Controller will try to apply latest used settings on launch.</label>
<h3>Minimize to tray:</h3>
<label><input class="uk-checkbox" type="checkbox" id="minimize_to_tray"> When checked, Ryzen Controller will minimize to tray instead of taskbar.</label>
<h3>Re-apply ryzenadj periodically:</h3>
<p>Ryzen Controller will re-apply ryzenadj every X seconds. Set to 0 to disable.</p>
<div class="uk-grid-small" uk-grid>
<div class="uk-width-1-6">
<input class="uk-input" type="number" min="0" step="10" max="3600" value="0" id="reapply_periodically" repeat="reapply_periodically_range">
</div>
<div class="uk-width-expand">
<input class="uk-range" type="range" min="0" step="10" max="3600" value="0" repeat="reapply_periodically" id="reapply_periodically_range">
</div>
</div>
<h3>Ryzenadj path:</h3>
<div class="uk-grid-small" uk-grid>
<div class="uk-width-2-3@s">

View File

@ -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;
});
/**

View File

@ -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);
}