2019-02-28 02:16:11 +07:00
|
|
|
ready(function(){
|
2019-07-25 18:51:32 +07:00
|
|
|
Sentry.init({
|
|
|
|
dsn: 'https://f80fd3ea297141a8bdc04ce812762f39@sentry.io/1513427',
|
|
|
|
release: require('./package.json').version,
|
|
|
|
});
|
2019-03-03 00:33:11 +07:00
|
|
|
const settings = require('electron-settings');
|
2019-04-07 18:52:05 +07:00
|
|
|
const fixPath = require('fix-path');
|
2019-03-01 23:12:05 +07:00
|
|
|
document.isStarting = true;
|
2019-04-07 18:52:05 +07:00
|
|
|
fixPath();
|
2019-07-04 23:27:22 +07:00
|
|
|
displayOptions();
|
2019-03-23 23:20:47 +07:00
|
|
|
preFillSettings();
|
|
|
|
loadLatestUsedSettings();
|
2019-02-28 05:02:10 +07:00
|
|
|
registerRepeaterForAllInput();
|
2019-03-01 00:40:42 +07:00
|
|
|
registerEventListenerForSettingsInput();
|
2019-02-28 05:02:10 +07:00
|
|
|
checkForAdminRights();
|
2019-03-01 21:38:59 +07:00
|
|
|
displayVersion();
|
2019-03-01 23:12:05 +07:00
|
|
|
reApplyPeriodically(require('electron-settings').get('settings.reapply_periodically'));
|
2019-03-13 02:04:02 +07:00
|
|
|
if (require('os').platform() === 'win32') {
|
2019-04-06 05:40:09 +07:00
|
|
|
recreateShortcut();
|
2019-03-11 18:57:42 +07:00
|
|
|
}
|
2019-04-06 05:40:09 +07:00
|
|
|
handlePlatformSpecificDisplay();
|
2019-06-04 17:23:28 +07:00
|
|
|
preset_updateList();
|
2019-03-08 19:02:14 +07:00
|
|
|
checkForNewRelease();
|
2019-03-01 23:12:05 +07:00
|
|
|
document.isStarting = false;
|
2019-06-03 17:17:13 +07:00
|
|
|
|
|
|
|
|
|
|
|
settings.set('settings',
|
|
|
|
Object.assign(
|
|
|
|
{},
|
|
|
|
settings.get('settings'),
|
|
|
|
{ first_launch: false }
|
|
|
|
)
|
|
|
|
);
|
2019-02-28 02:16:11 +07:00
|
|
|
});
|
2019-02-28 03:04:28 +07:00
|
|
|
|
2019-02-28 05:02:10 +07:00
|
|
|
/**
|
|
|
|
* Will create and handle ryzenadj.exe execution.
|
|
|
|
*/
|
2019-03-01 00:39:33 +07:00
|
|
|
function applyRyzenSettings() {
|
2019-03-08 02:00:12 +07:00
|
|
|
const settings = getCurrentSettings("ryzenadjArgs");
|
2019-06-01 21:17:48 +07:00
|
|
|
const appSettings = require('electron-settings');
|
2019-02-28 03:04:28 +07:00
|
|
|
|
|
|
|
const child = require('child_process').execFile;
|
2019-02-28 14:11:03 +07:00
|
|
|
const executablePath = getRyzenAdjExecutablePath();
|
2019-02-28 03:04:28 +07:00
|
|
|
|
2019-07-04 23:27:22 +07:00
|
|
|
const options_data = require('./js/options_data.json');
|
|
|
|
const ryzenAdjConvert = {
|
|
|
|
"toHex": function (value) { return '0x' + decimalToHexString(value * 1000); },
|
|
|
|
"toThousand": function (value) { return value * 1000; },
|
|
|
|
"roundTen": function (value) { return parseInt(value / 10) * 10; },
|
|
|
|
};
|
|
|
|
|
|
|
|
// Create a string to be used for CLI.
|
2019-02-28 03:04:28 +07:00
|
|
|
var parameters = [];
|
|
|
|
for (const option in settings) {
|
|
|
|
if (settings.hasOwnProperty(option)) {
|
|
|
|
let value = settings[option];
|
2019-07-04 23:27:22 +07:00
|
|
|
let option_name = false;
|
|
|
|
try {
|
|
|
|
option_name = Object.keys(options_data).filter(function(cur_option_name){
|
|
|
|
return options_data[cur_option_name].ryzenadj_arg === option;
|
|
|
|
})[0];
|
|
|
|
} catch (error) {
|
|
|
|
notification('danger', `Unknown option "${option}".`);
|
|
|
|
appendLog(`applyRyzenSettings(): ${error}`);
|
2019-07-25 18:51:32 +07:00
|
|
|
Sentry.captureException(new Error(`applyRyzenSettings(): ${error}`));
|
2019-07-04 23:27:22 +07:00
|
|
|
}
|
|
|
|
if (options_data[option_name].ryzenadj_value_convert) {
|
|
|
|
value = ryzenAdjConvert[
|
|
|
|
options_data[option_name].ryzenadj_value_convert
|
|
|
|
](value);
|
2019-02-28 03:04:28 +07:00
|
|
|
}
|
|
|
|
parameters.push('' + option + value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-01 21:17:48 +07:00
|
|
|
if (!appSettings.get('retry')) {
|
|
|
|
appSettings.set('retry', 2);
|
|
|
|
notification('warning', 'Applying settings...');
|
|
|
|
} else {
|
|
|
|
let retry = appSettings.get('retry') - 1;
|
|
|
|
appSettings.set('retry', retry);
|
|
|
|
}
|
2019-02-28 03:04:28 +07:00
|
|
|
child(executablePath, parameters, function(err, data) {
|
2019-02-28 05:02:10 +07:00
|
|
|
var output = data.toString();
|
|
|
|
if (err) {
|
2019-06-03 01:59:32 +07:00
|
|
|
if (appSettings.get('retry')) {
|
|
|
|
return setTimeout(applyRyzenSettings, 500);
|
2019-06-01 21:17:48 +07:00
|
|
|
}
|
2019-02-28 05:02:10 +07:00
|
|
|
notification('danger', err + '<br/>' + output);
|
2019-07-25 18:51:32 +07:00
|
|
|
Sentry.captureException(new Error(err + ' - ' + output));
|
2019-02-28 05:02:10 +07:00
|
|
|
}
|
|
|
|
else if (output) {
|
|
|
|
notification('success', 'Ryzenadj output:<br/>' + output);
|
2019-03-01 00:23:05 +07:00
|
|
|
saveLatestUsedSettings();
|
2019-02-28 05:02:10 +07:00
|
|
|
}
|
2019-06-03 01:59:32 +07:00
|
|
|
appSettings.set('retry', false);
|
2019-02-28 03:04:28 +07:00
|
|
|
});
|
|
|
|
|
|
|
|
}
|