Fix #3 Added start on boot settings.

This commit is contained in:
Quentin Decaunes 2019-03-02 16:23:10 +01:00
parent 7182f1d9a5
commit f511c4aa0a
3 changed files with 14 additions and 0 deletions

View File

@ -70,6 +70,8 @@
</li> </li>
<li class="uk-container uk-animation-fade"> <li class="uk-container uk-animation-fade">
<h3>Auto start with system:</h3>
<label><input class="uk-checkbox" type="checkbox" id="start_at_boot"> When checked, Ryzen Controller will start on system login.</label>
<h3>Auto apply on launch:</h3> <h3>Auto apply on launch:</h3>
<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> <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> <h3>Minimize to tray:</h3>

View File

@ -116,6 +116,7 @@ function preFillSettings() {
notification('danger', "Path to ryzenadj.exe is wrong, please fix it in settings tab."); notification('danger', "Path to ryzenadj.exe is wrong, please fix it in settings tab.");
} }
const settings = require('electron-settings'); const settings = require('electron-settings');
document.getElementById('start_at_boot').checked = !!settings.get('settings.start_at_boot');
document.getElementById('apply_last_settings_on_launch').checked = !!settings.get('settings.apply_last_settings_on_launch'); 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('minimize_to_tray').checked = !!settings.get('settings.minimize_to_tray');
@ -228,6 +229,14 @@ function registerEventListenerForSettingsInput() {
reapply_periodically: reapply_periodically.value reapply_periodically: reapply_periodically.value
}); });
}); });
var start_at_boot = document.getElementById('start_at_boot');
start_at_boot.addEventListener('change', function() {
settings.set('settings', {
...settings.get('settings'),
start_at_boot: !!start_at_boot.checked
});
require('electron').remote.app.setLoginItemSettings({ openAtLogin: !!start_at_boot.checked });
});
} }
/** /**

View File

@ -9,6 +9,9 @@ if (setupEvents.handleSquirrelEvent()) {
const {app, BrowserWindow, Menu, Tray} = require('electron') const {app, BrowserWindow, Menu, Tray} = require('electron')
const settings = require('electron-settings'); const settings = require('electron-settings');
// Check and apply start_on_boot option.
app.setLoginItemSettings({ openAtLogin: !!settings.get('settings.start_at_boot') });
// Check for latest used version and clear settings if needed. // Check for latest used version and clear settings if needed.
if (settings.get('settings.last_used_version') !== require('./package.json').version) { if (settings.get('settings.last_used_version') !== require('./package.json').version) {
settings.delete('settings.ryzen_adj_path'); settings.delete('settings.ryzen_adj_path');