https://github.com/131/trayicon
node system tray trayicon helper
https://github.com/131/trayicon
icon icons nodejs systray systray-icon tray-icon tray-menu
Last synced: 9 months ago
JSON representation
node system tray trayicon helper
- Host: GitHub
- URL: https://github.com/131/trayicon
- Owner: 131
- License: mit
- Created: 2020-11-25T17:26:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T17:46:12.000Z (over 2 years ago)
- Last Synced: 2024-10-28T23:13:20.917Z (over 1 year ago)
- Topics: icon, icons, nodejs, systray, systray-icon, tray-icon, tray-menu
- Language: C#
- Homepage:
- Size: 51.8 KB
- Stars: 13
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/131/trayicon/actions/workflows/deploy.yml)
[](https://www.npmjs.com/package/trayicon)
[](http://opensource.org/licenses/MIT)
[](https://www.npmjs.com/package/eslint-plugin-ivs)

# Motivation
[trayicon](https://github.com/131/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, useTempDir} [, 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.
Set `useTempDir` to `true` or `"clean"` to copy executable files to temporary directory (`clean` removes temp files on `tray.kill()`). Allows using the package with [pkg](https://www.npmjs.com/package/pkg).
## `(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
* [131](https://github.com/131)
* [murrayju](https://github.com/murrayju/CreateProcessAsUser)
* Code signing, courtesy of IVS Group.