trayicon

trayicon provide you system tray icon for your nodejs application.

Usage no npm install needed!

<script type="module">
  import trayicon from 'https://cdn.skypack.dev/trayicon';
</script>

README

Build Status Version License Code style Available platform

Motivation

trayicon provide you system tray icon for your nodejs application.

Usage example

const Tray = require('trayicon');

Tray.create(function(tray) {
  let main = tray.item("Power");
  main.add(tray.item("on"), tray.item("on"));

  let quit = tray.item("Quit", () => tray.kill());
  tray.setMenu(main, quit);
});

API

(Promise ) tray.create({icon, title, action} [, readyCb])

Create a new Tray instance, return a promise / emit a callback when the trayicon is ready. If defined, action callback is triggered when double clicking the tray.

(void) tray.setTitle(tray title)

Set the systray title.

(void) tray.setIcon(binary icon buffer)

Set the systray icon.

(void) tray.notify("Some title", "Some message")

Display a notification balloon.

(void) tray.setMenu(...items)

Set the systray menu.

(Item) tray.item("foo", { ?checked : boolean, ?disabled : boolean, ?bold : boolean, ?action : function})

Create a menu item. If defined, the action callback is triggered when the item is selected.

(void) parentItem.add(...childrenItems)

Create a submenu of childrenItems under parentItem.

(Item) tray.separator();

Create an item of type "separator"

Extra features

  • Work when running node as SYSTEM\NT authority (trayicon will fallback to interactive session if needed)

Credits