diff --git a/app/main.js b/app/main.js index 9efc7fe..ddf777c 100644 --- a/app/main.js +++ b/app/main.js @@ -1,4 +1,4 @@ -const { app, Menu, BrowserWindow, dialog } = require("electron"); +const { app, Menu, BrowserWindow, dialog, nativeImage } = require("electron"); const { autoUpdater } = require("electron-updater"); const checkInternetConnected = require("check-internet-connected"); const ElectronDl = require("electron-dl"); @@ -166,81 +166,134 @@ app.on("web-contents-created", (event, contents) => { } }); contents.on("did-finish-load", () => { - try { - if ( - BrowserWindow.getFocusedWindow() - .webContents.getTitle() - .includes("Microsoft PowerPoint") - ) { - if (process.platform === "darwin") { - app.dock.setIcon( - path.join(__dirname, "../assets/icons/apps/powerpoint-mac.png") - ); - } - } else if ( - BrowserWindow.getFocusedWindow() - .webContents.getTitle() - .includes("Microsoft Word") - ) { - if (process.platform === "darwin") { - app.dock.setIcon( - path.join(__dirname, "../assets/icons/apps/word-mac.png") - ); - } - } else if ( - BrowserWindow.getFocusedWindow() - .webContents.getTitle() - .includes("Microsoft Excel") - ) { - if (process.platform === "darwin") { - app.dock.setIcon( - path.join(__dirname, "../assets/icons/apps/excel-mac.png") - ); - } - } else if ( - BrowserWindow.getFocusedWindow() - .webContents.getTitle() - .includes("Outlook") - ) { - if (process.platform === "darwin") { - app.dock.setIcon( - path.join(__dirname, "../assets/icons/apps/outlook-mac.png") - ); - } - } else if ( - BrowserWindow.getFocusedWindow() - .webContents.getTitle() - .includes("OneDrive") - ) { - if (process.platform === "darwin") { - app.dock.setIcon( - path.join(__dirname, "../assets/icons/apps/onedrive-mac.png") - ); - } - } else if ( - BrowserWindow.getFocusedWindow() - .webContents.getTitle() - .includes("Microsoft Teams") - ) { - if (process.platform === "darwin") { - app.dock.setIcon( - path.join(__dirname, "../assets/icons/apps/teams-mac.png") - ); - } - } else if ( - BrowserWindow.getFocusedWindow() - .webContents.getTitle() - .includes("Microsoft OneNote Online") - ) { - if (process.platform === "darwin") { - app.dock.setIcon( - path.join(__dirname, "../assets/icons/apps/onenote-mac.png") - ); - } - } else { - app.dock.setIcon(null); + if ( + BrowserWindow.getFocusedWindow() + .webContents.getTitle() + .includes("Microsoft PowerPoint") + ) { + if (process.platform === "darwin") { + app.dock.setIcon( + path.join(__dirname, "../assets/icons/apps/powerpoint-mac.png") + ); + } else if (process.platform === "win32") { + let nimage = nativeImage.createFromPath( + path.join(__dirname, "../assets/icons/apps/powerpoint.png") + ); + BrowserWindow.getAllWindows().forEach((window) => { + window.setOverlayIcon(nimage, "PowerPoint"); + }); } - } catch {} + } else if ( + BrowserWindow.getFocusedWindow() + .webContents.getTitle() + .includes("Microsoft Word") + ) { + if (process.platform === "darwin") { + app.dock.setIcon( + path.join(__dirname, "../assets/icons/apps/word-mac.png") + ); + } else if (process.platform === "win32") { + let nimage = nativeImage.createFromPath( + path.join(__dirname, "../assets/icons/apps/word.png") + ); + BrowserWindow.getAllWindows().forEach((window) => { + window.setOverlayIcon(nimage, "Word"); + }); + } + } else if ( + BrowserWindow.getFocusedWindow() + .webContents.getTitle() + .includes("Microsoft Excel") + ) { + if (process.platform === "darwin") { + app.dock.setIcon( + path.join(__dirname, "../assets/icons/apps/excel-mac.png") + ); + } else if (process.platform === "win32") { + let nimage = nativeImage.createFromPath( + path.join(__dirname, "../assets/icons/apps/excel.png") + ); + BrowserWindow.getAllWindows().forEach((window) => { + window.setOverlayIcon(nimage, "Excel"); + }); + } + } else if ( + BrowserWindow.getFocusedWindow() + .webContents.getTitle() + .includes("Outlook") + ) { + if (process.platform === "darwin") { + app.dock.setIcon( + path.join(__dirname, "../assets/icons/apps/outlook-mac.png") + ); + } else if (process.platform === "win32") { + let nimage = nativeImage.createFromPath( + path.join(__dirname, "../assets/icons/apps/outlook.png") + ); + BrowserWindow.getAllWindows().forEach((window) => { + window.setOverlayIcon(nimage, "Outlook"); + }); + } + } else if ( + BrowserWindow.getFocusedWindow() + .webContents.getTitle() + .includes("OneDrive") + ) { + if (process.platform === "darwin") { + app.dock.setIcon( + path.join(__dirname, "../assets/icons/apps/onedrive-mac.png") + ); + } else if (process.platform === "win32") { + let nimage = nativeImage.createFromPath( + path.join(__dirname, "../assets/icons/apps/onedrive.png") + ); + BrowserWindow.getAllWindows().forEach((window) => { + window.setOverlayIcon(nimage, "OneDrive"); + }); + } + } else if ( + BrowserWindow.getFocusedWindow() + .webContents.getTitle() + .includes("Microsoft Teams") + ) { + if (process.platform === "darwin") { + app.dock.setIcon( + path.join(__dirname, "../assets/icons/apps/teams-mac.png") + ); + } else if (process.platform === "win32") { + let nimage = nativeImage.createFromPath( + path.join(__dirname, "../assets/icons/apps/teams.png") + ); + BrowserWindow.getAllWindows().forEach((window) => { + window.setOverlayIcon(nimage, "Teams"); + }); + } + } else if ( + BrowserWindow.getFocusedWindow() + .webContents.getTitle() + .includes("Microsoft OneNote Online") + ) { + if (process.platform === "darwin") { + app.dock.setIcon( + path.join(__dirname, "../assets/icons/apps/onenote-mac.png") + ); + } else if (process.platform === "win32") { + let nimage = nativeImage.createFromPath( + path.join(__dirname, "../assets/icons/apps/onenote.png") + ); + BrowserWindow.getAllWindows().forEach((window) => { + window.setOverlayIcon(nimage, "OneNote"); + }); + } + } else { + if (process.platform === "darwin") { + app.dock.setIcon(null); + } else { + BrowserWindow.getAllWindows().forEach((window) => { + window.setOverlayIcon(null, ""); + }); + } + } }); }); diff --git a/assets/icons/apps/excel.png b/assets/icons/apps/excel.png new file mode 100644 index 0000000..9d6dea5 Binary files /dev/null and b/assets/icons/apps/excel.png differ diff --git a/assets/icons/apps/onedrive.png b/assets/icons/apps/onedrive.png new file mode 100644 index 0000000..b5c24bc Binary files /dev/null and b/assets/icons/apps/onedrive.png differ diff --git a/assets/icons/apps/onenote.png b/assets/icons/apps/onenote.png new file mode 100644 index 0000000..eb5157b Binary files /dev/null and b/assets/icons/apps/onenote.png differ diff --git a/assets/icons/apps/outlook.png b/assets/icons/apps/outlook.png new file mode 100644 index 0000000..3f2bbb4 Binary files /dev/null and b/assets/icons/apps/outlook.png differ diff --git a/assets/icons/apps/powerpoint.png b/assets/icons/apps/powerpoint.png new file mode 100644 index 0000000..6247923 Binary files /dev/null and b/assets/icons/apps/powerpoint.png differ diff --git a/assets/icons/apps/teams.png b/assets/icons/apps/teams.png new file mode 100644 index 0000000..a71cef9 Binary files /dev/null and b/assets/icons/apps/teams.png differ diff --git a/assets/icons/apps/word.png b/assets/icons/apps/word.png new file mode 100644 index 0000000..d406b06 Binary files /dev/null and b/assets/icons/apps/word.png differ