0.1.1 • Published 7 years ago

electron-tray v0.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

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?).
  • Basic functionality works. You can haz icon, and menu.