slackgmailskypefacebook-workplaceoutlookemailmicrosoft-teamsdiscordmessengercustom-servicesmacoslinuxwindowsinboxwhatsappicloudtweetdeckhipchattelegramhangouts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.4 KiB
66 lines
1.4 KiB
const path = require('path'); |
|
const electron = require('electron'); |
|
const app = electron.app; |
|
// Module to create tray icon |
|
const Tray = electron.Tray; |
|
|
|
const MenuItem = electron.MenuItem; |
|
var appIcon = null; |
|
|
|
exports.create = function(win, mainWindowState) { |
|
if (process.platform === 'darwin' || appIcon) { |
|
return; |
|
} |
|
|
|
const icon = process.platform === 'linux' || process.platform === 'darwin' ? 'IconTray.png' : 'Icon.ico'; |
|
const iconPath = path.join(__dirname, `../resources/${icon}`); |
|
|
|
const toggleWin = () => { |
|
if (win.isVisible()) { |
|
win.hide(); |
|
} else { |
|
win.show(); |
|
} |
|
}; |
|
|
|
const contextMenu = electron.Menu.buildFromTemplate([ |
|
{ |
|
label: 'Show/Hide Window' |
|
,click() { |
|
toggleWin(); |
|
} |
|
}, |
|
{ |
|
type: 'separator' |
|
}, |
|
{ |
|
label: 'Quit' |
|
,click() { |
|
app.quit(); |
|
} |
|
} |
|
]); |
|
|
|
appIcon = new Tray(iconPath); |
|
appIcon.setToolTip('Rambox'); |
|
appIcon.setContextMenu(contextMenu); |
|
appIcon.on('double-click', () => { |
|
mainWindowState.isMaximized ? win.maximize() : win.show(); |
|
}); |
|
}; |
|
|
|
exports.setBadge = shouldDisplayUnread => { |
|
if (process.platform === 'darwin' || !appIcon) { |
|
return; |
|
} |
|
|
|
let icon; |
|
if (process.platform === 'linux') { |
|
icon = shouldDisplayUnread ? 'IconTrayUnread.png' : 'IconTray.png'; |
|
} else { |
|
icon = shouldDisplayUnread ? 'IconTrayUnread.ico' : 'Icon.ico'; |
|
} |
|
|
|
const iconPath = path.join(__dirname, `../resources/${icon}`); |
|
appIcon.setImage(iconPath); |
|
};
|
|
|