Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.

Commit

Permalink
now it brings up the application to the focus when you click on the n…
Browse files Browse the repository at this point in the history
…otification
  • Loading branch information
netharuM committed Feb 7, 2022
1 parent 298e3c6 commit 0ea3b92
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/bell.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { shell } = require("electron");
const { shell, ipcRenderer } = require("electron");
const path = require("path");
const fs = require("fs");
const _ = require("lodash");
Expand Down Expand Up @@ -329,6 +329,9 @@ class bell {
icon: path.resolve(__dirname, "../assets/icon.png"),
}
);
this.bellNotification.addEventListener("click", () => {
ipcRenderer.send("focusWindow");
});
clearTimeout(this.bellNotificationTimeOut);
}, this.eta() - 60000);
var { bell, dropDown } = this.createBellElement();
Expand Down
9 changes: 8 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ const createWindow = () => {
}
});
}

ipcMain.on("focusWindow", (event, arg) => {
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore();
}
mainWindow.show();
}
});
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 1080,
Expand Down
6 changes: 5 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ settingsHandler.onAudioBellOutChange = (e) => {
bellHandler.setBellAudioOutput(e.target.value);
};

new Notification("auto-bell", {
let running = new Notification("auto-bell", {
body: "auto-bell is running",
icon: path.resolve(__dirname, "../assets/icon.png"),
});

running.onclick = () => {
ipcRenderer.send("focusWindow");
};

0 comments on commit 0ea3b92

Please sign in to comment.