electron-tray
v0.1.1
Published
Very simple package to add tray icon behaviour to an electron app
Downloads
46
Readme
Quickly add a tray icon to an electron app
Very basic at the moment, this module is either going nowhere or I might extend it to deal with app lifecycle management, window toggling etc.
Usage:
const trayControl = new TrayControl(electron.app, iconPath[, menu]);
...where menu
is passed to electron.MenuItem
via electron.Menu.buildFromTemplate()
i.e. it's just a normal electron menu.
Example:
import path from 'path';
import electron from 'electron';
const app = electron.app;
import TrayControl from 'electron-tray';
const iconPath = path.join(__dirname, 'icon.png');
// Keep this reference around otherwise the icon will
// vanish when the TrayControl instance gets GCed.
const trayControl = new TrayControl(app, iconPath);
// ... initialise your app here as normal ...
Changes
- [ ] If clean way to do it, add ability to persist app while all windows are closed, minimise/close to tray etc.
- [ ] If Windows machine available, investigate integration of
electron-promote-windows-tray-items
(Issues #1 and #2 may be blockers and will this thing even work with newer electron versions?). - [x] Basic functionality works. You can haz icon, and menu.