From a36b59792e85ae0bd57fc452257473dfccf9495e Mon Sep 17 00:00:00 2001 From: Nicholas Tay Date: Sun, 14 Aug 2022 17:00:58 +1000 Subject: Tweak macOS menu bar --- main.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 566a954..b528725 100644 --- a/main.js +++ b/main.js @@ -3,6 +3,9 @@ const path = require('path'); const config = require(path.join(__dirname, 'config.json')); +if (config.name) + app.setName(config.name); + // Load flash let flash; if (process.arch !== 'x64') @@ -26,6 +29,16 @@ app.commandLine.appendSwitch('ppapi-flash-version', '32.0.0.371'); // Menu // https://www.electronjs.org/docs/latest/api/menu const menuTemplate = [ + // macOS first menu is always the "app name" one. + ...(process.platform === 'darwin' ? [{ + label: app.name, + submenu: [ + { role: 'about' }, + { type: 'separator' }, + { role: 'quit' } + ] + }] : []), + { label: 'File', submenu: Object.keys(config.urls).map(urlName => ({ @@ -33,7 +46,7 @@ const menuTemplate = [ click: function(menuItem, browserWindow, event) { browserWindow.loadURL(config.urls[urlName]); } - })).concat([ + })).concat(process.platform === 'darwin' ? [] : [ { type: 'separator' }, { role: 'quit' } ]) @@ -83,4 +96,4 @@ app.whenReady().then(() => { app.on('window-all-closed', () => { // Quit when all windows closed - even on macOS. app.quit() -}); \ No newline at end of file +}); -- cgit