Skip to content

Instantly share code, notes, and snippets.

@adodado
Created September 16, 2021 09:02
Show Gist options
  • Save adodado/40eb852a20361f7e955b9ef080854002 to your computer and use it in GitHub Desktop.
Save adodado/40eb852a20361f7e955b9ef080854002 to your computer and use it in GitHub Desktop.
Building a Cross-Platform Desktop Notification Application with Electron initial Index.js
const { app, Tray, Menu } = require("electron");
const path = require("path");
const iconPath = path.join(__dirname, "icon.png");
let trayApp = null;
function getContextMenu() {
let contextMenu = Menu.buildFromTemplate([
{
label: "Exit",
click: function () {
app.exit();
},
},
]);
return contextMenu;
}
app.on("ready", () => {
trayApp = new Tray(iconPath);
var contextMenu = getContextMenu();
trayApp.setToolTip("BreakTime Buddy");
trayApp.setContextMenu(contextMenu);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment