mirror of
https://gitlab.com/ryzen-controller-team/ryzen-controller.git
synced 2024-12-22 10:03:28 +07:00
feat: #3 Auto start on windows session login.
This commit is contained in:
parent
1a1990b9ad
commit
b5b9b3c839
@ -42,8 +42,8 @@
|
||||
</li>
|
||||
|
||||
<li class="uk-margin-top uk-margin-bottom uk-container">
|
||||
<!-- <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 class="windows-only">Auto start:</h3>
|
||||
<label class="windows-only"><input class="uk-checkbox" type="checkbox" id="start_at_boot"> When checked, Ryzen Controller will start on session start.</label>
|
||||
<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>
|
||||
<h3>Minimize to tray:</h3>
|
||||
|
@ -208,7 +208,7 @@ function preFillSettings() {
|
||||
notification('danger', "Path to ryzenadj.exe is wrong, please fix it in settings tab.");
|
||||
}
|
||||
const settings = require('electron-settings');
|
||||
// document.getElementById('start_at_boot').checked = !!settings.get('settings.start_at_boot');
|
||||
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('minimize_to_tray').checked = !!settings.get('settings.minimize_to_tray');
|
||||
document.getElementById('start_minimized').checked = !!settings.get('settings.start_minimized');
|
||||
@ -391,20 +391,20 @@ function registerEventListenerForSettingsInput() {
|
||||
);
|
||||
|
||||
});
|
||||
// var start_at_boot = document.getElementById('start_at_boot');
|
||||
// start_at_boot.addEventListener('change', function() {
|
||||
//
|
||||
// settings.set(
|
||||
// "settings",
|
||||
// Object.assign(
|
||||
// {},
|
||||
// settings.get('settings'),
|
||||
// { start_at_boot: !!start_at_boot.checked }
|
||||
// )
|
||||
// );
|
||||
//
|
||||
// require('electron').remote.app.setLoginItemSettings({ openAtLogin: !!start_at_boot.checked });
|
||||
// });
|
||||
var start_at_boot = document.getElementById('start_at_boot');
|
||||
start_at_boot.addEventListener('change', function() {
|
||||
|
||||
settings.set(
|
||||
"settings",
|
||||
Object.assign(
|
||||
{},
|
||||
settings.get('settings'),
|
||||
{ start_at_boot: !!start_at_boot.checked }
|
||||
)
|
||||
);
|
||||
|
||||
updateScheduledStartOnBoot(!!start_at_boot.checked);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -564,3 +564,25 @@ function handlePlatformSpecificDisplay() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Will delete scheduled task to start ryzen controller on session start then recreate it if isEnable is true.
|
||||
*
|
||||
* @param {bool} toBeEnabled Is auto launch should be enabled?
|
||||
*/
|
||||
function updateScheduledStartOnBoot(toBeEnabled) {
|
||||
const app = require('electron').remote.app;
|
||||
window.app = app;
|
||||
const AutoLaunch = require('auto-launch');
|
||||
let autoLaunch = new AutoLaunch({
|
||||
name: 'Ryzen Controller'
|
||||
});
|
||||
autoLaunch.isEnabled().then((isEnabled) => {
|
||||
console.log(`toBeEnabled: ${toBeEnabled} isEnabled: ${isEnabled}`);
|
||||
if (toBeEnabled && !isEnabled) {
|
||||
autoLaunch.enable();
|
||||
} else {
|
||||
autoLaunch.disable();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
11
main.js
11
main.js
@ -8,9 +8,6 @@ if (!setupEvents.handleSquirrelEvent()) {
|
||||
const {app, BrowserWindow, Menu, Tray} = require('electron')
|
||||
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.
|
||||
const old_version = settings.get('settings.last_used_version');
|
||||
const new_version = require('./package.json').version;
|
||||
@ -110,6 +107,14 @@ if (!setupEvents.handleSquirrelEvent()) {
|
||||
settings.set('latest_controller_tabs_settings', update_preset_to_1_12_0(settings.get('latest_controller_tabs_settings')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Since 1.14.0, login managed through s=windows scheduler
|
||||
*/
|
||||
if (compareVersions(old_version, '1.14.0') <= 0) {
|
||||
// Ensure login on start false.
|
||||
app.setLoginItemSettings({ openAtLogin: false });
|
||||
}
|
||||
|
||||
settings.set('settings',
|
||||
Object.assign(
|
||||
{},
|
||||
|
847
package-lock.json
generated
847
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -31,6 +31,7 @@
|
||||
"electron-packager": "^13.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"auto-launch": "^5.0.5",
|
||||
"compare-versions": "^3.4.0",
|
||||
"electron-settings": "^3.2.0",
|
||||
"fix-path": "^2.1.0",
|
||||
|
Loading…
Reference in New Issue
Block a user