Skip to content

Commit

Permalink
Merge pull request #18 from Izurii/first-run
Browse files Browse the repository at this point in the history
Update version and electron-first-run package added
  • Loading branch information
Izurii authored Apr 13, 2021
2 parents 1c28af9 + 5aba17a commit 6469496
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
18 changes: 12 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const { exec, spawn } = require('child_process');
const AutoLaunch = require('auto-launch');
const Store = require('electron-store');
const path = require('path');
const firstRun = require('electron-first-run');

const isFirstRun = firstRun();

const LedController = new AutoLaunch({
name: 'Lenovo Y720 Led Controller',
Expand Down Expand Up @@ -117,8 +120,8 @@ const setMenu = () => {
if(!app.requestSingleInstanceLock()) {
app.quit();
} else {
app.on('second-instance', () => {

app.on('second-instance', () => {
if (mainWindow) {
if(mainWindow.isMinimized()) mainWindow.restore(); else if(!mainWindow.isVisible()) mainWindow.show();
mainWindow.focus();
Expand All @@ -130,6 +133,12 @@ if(!app.requestSingleInstanceLock()) {
let profiles = getProfilesFunc();
let selectedProfile = profiles.profiles[profiles.selectedProfile];

let backgroundNotification = new Notification({
icon: frogIcon,
title: 'Lenovo Y720 Keyboard Controller',
body: "I'm on the background, open me again using the tray menu"
});

setKeyboardOptions(selectedProfile.backlightMode, selectedProfile.profileOptions, app.getPath('userData'));

tray = new Tray(frogIcon);
Expand All @@ -149,6 +158,7 @@ if(!app.requestSingleInstanceLock()) {
maxWidth:1510,
autoHideMenuBar:true,
icon: frogIcon,
show: isFirstRun ? true : false
});

app.allowRendererProcessReuse = false;
Expand All @@ -160,11 +170,7 @@ if(!app.requestSingleInstanceLock()) {
if(!trayQuit) {
event.preventDefault();
mainWindow.hide();
new Notification({
icon: frogIcon,
title: 'Lenovo Y720 Keyboard Controller',
body: "I'm on the background, open me again using the tray menu"
}).show();
if (isFirstRun) backgroundNotification.show();
}
});

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"node": "=14.16.0"
},
"engineStrict": true,
"version": "v1.7.23-genesis",
"version": "v1.7.24-genesis",
"description": "",
"main": "main.js",
"author": "Izurii Hootoh <izuriihootoh@gmail.com> (https://github.com/Izurii)",
Expand Down Expand Up @@ -57,6 +57,7 @@
"angular-material": "^1.2.2",
"angular-route": "^1.8.2",
"auto-launch": "^5.0.5",
"electron-first-run": "^3.0.0",
"electron-store": "^7.0.2",
"ioctl": "^2.0.2",
"proper-lockfile": "^4.1.2"
Expand Down

0 comments on commit 6469496

Please sign in to comment.