Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ahkohd committed Oct 27, 2019
2 parents 08f0f0e + 2c3a15b commit ba15c34
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ node_modules
dist/*
app/*
!app/.gitkeep
service-binaries/*.dll
service-binaries/*.node
service-binaries/**/*.exe
service-binaries


9 changes: 7 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Modules to control application life and create native browser window
const { app, BrowserWindow } = require("electron");
const { app, BrowserWindow, ipcMain } = require("electron");
const path = require("path");
const Positioner = require("electron-positioner");
const { execFile } = require("child_process");
Expand Down Expand Up @@ -104,7 +104,8 @@ if (!gotTheLock) {
placement == "right"
? mainWindow.setPosition(pos[0] - 10, pos[1])
: mainWindow.setPosition(pos[0] + 10, pos[1]);
mainWindow.show();
// delay a bit
setTimeout(() => mainWindow.show(), 1000);
});

// spawn the executable approraite for the windows os.
Expand Down Expand Up @@ -139,4 +140,8 @@ if (!gotTheLock) {

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

ipcMain.on("quit-switch", function(event, arg) {
app.exit(0);
});
}
24 changes: 16 additions & 8 deletions preload.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { remote, app } = require("electron");
const { remote, app, ipcRenderer } = require("electron");

const find = require("find-process");
const ps = require("ps-node");
Expand Down Expand Up @@ -113,7 +113,7 @@ createSettingsWindow = () => {

const trayMenuTemplate = [
{
label: "Show dock",
label: "Show dock...",
click: () => {
try {
window.SWITCH_SERVICE_CHANNEL.emit(
Expand All @@ -127,14 +127,19 @@ const trayMenuTemplate = [
},

{
label: "Settings",
label: "Preferences...",
click: () => createSettingsWindow(),
enabled: !settingsWindowOpened
},
{
type: "separator"
},
{
label: "Quit",
click: function() {
app.quit();
click: () => {
// stop swicth service...
if (process.platform == "darwin") StartOrStopSwitchMacService(false);
ipcRenderer.send("quit-switch");
}
}
];
Expand All @@ -143,7 +148,10 @@ if (process.platform == "darwin") {
// If platform is mac add extra menu item to cater for starting
// and stoping services ...
trayMenuTemplate.unshift({
label: "Off 🧯",
type: "separator"
});
trayMenuTemplate.unshift({
label: "Turn Off",
click: () => {
StartOrStopSwitchMacService(false);
}
Expand Down Expand Up @@ -193,12 +201,12 @@ function StartOrStopSwitchMacService(start = true) {
child = SPWAN_SWITCH_SERVICE_MAC();
});

trayMenuTemplate[0].label = "Off 🧯";
trayMenuTemplate[0].label = "Turn Off";
trayMenuTemplate[0].click = () => {
StartOrStopSwitchMacService(false);
};
} else {
trayMenuTemplate[0].label = "On 🔥";
trayMenuTemplate[0].label = "Turn On";
trayMenuTemplate[0].click = () => {
StartOrStopSwitchMacService(true);
};
Expand Down

0 comments on commit ba15c34

Please sign in to comment.