lbry-desktop/electron/createTray.js

45 lines
894 B
JavaScript
Raw Normal View History

2018-02-27 05:03:01 +01:00
import { app, Menu, Tray } from 'electron';
2018-02-24 00:20:12 +01:00
import path from 'path';
2019-03-16 00:16:11 +01:00
let tray;
2018-02-24 00:20:12 +01:00
export default window => {
let iconPath;
2019-03-15 23:09:14 +01:00
2018-02-24 00:20:12 +01:00
switch (process.platform) {
case 'darwin': {
2019-03-05 05:46:57 +01:00
iconPath = 'static/img/tray/mac/trayTemplate.png';
2018-02-24 00:20:12 +01:00
break;
}
case 'win32': {
2019-03-05 05:46:57 +01:00
iconPath = 'static/img/tray/windows/tray.ico';
2018-02-24 00:20:12 +01:00
break;
}
default: {
2019-03-05 05:46:57 +01:00
iconPath = 'static/img/tray/default/tray.png';
2018-02-24 00:20:12 +01:00
}
}
2019-05-07 23:38:29 +02:00
tray = new Tray(process.env.NODE_ENV === 'development' ? iconPath : path.join(process.resourcesPath, iconPath));
2018-02-24 00:20:12 +01:00
tray.on('double-click', () => {
window.show();
});
tray.setToolTip('LBRY App');
const template = [
{
label: `Open ${app.getName()}`,
click: () => {
window.show();
},
},
{ role: 'quit' },
];
const contextMenu = Menu.buildFromTemplate(template);
tray.setContextMenu(contextMenu);
return tray;
};