node-systray-v2
is a very simple cross-platform systray library for node.js with precompiled binaries. It is a successor of the now unmaintained library node-systray.
It picks and uses precompiled executables under the hood based on what OS it's running on and communicates with them through stdin/stdout, so it works just out of the box.
✨ No need to compile ANYTHING. No headaces with those native addons, compilation or anything like that. Just add the module and use.
npm install --save https://github.com/Edgar-P-yan/node-systray-v2
# For Yarn, use the command below.
yarn add https://github.com/Edgar-P-yan/node-systray-v2
Source code of this preview is at ./examples/preview/.
import SysTray from 'systray';
const systray = new SysTray({
menu: {
// you should using .png icon in macOS/Linux, but .ico format in windows
icon: '<base64 png/ico string>',
title: '标题',
tooltip: 'Tips',
items: [
{
title: 'aa',
tooltip: 'bb',
// checked is implement by plain text in linux
checked: true,
enabled: true,
},
{
title: 'aa2',
tooltip: 'bb',
checked: false,
enabled: true,
},
{
title: 'Exit',
tooltip: 'bb',
checked: false,
enabled: true,
},
],
},
debug: false,
copyDir: true, // copy go tray binary to outside directory, useful for packing tool like pkg.
});
systray.onClick((action) => {
if (action.seq_id === 0) {
systray.sendAction({
type: 'update-item',
item: {
...action.item,
checked: !action.item.checked,
},
seq_id: action.seq_id,
});
} else if (action.seq_id === 1) {
// open the url
console.log('open the url', action);
} else if (action.seq_id === 2) {
systray.kill();
}
});
Take a look at the examples.
Documentation generated from source files by Typedoc.
- Add more examples and docs with screenshots
- Submenus, dividers, fixes, most of which can be taken from awesome but now unmaintained fork felixhao28/node-systray
- Write some tests (maybe even e2e)
Released under MIT License.