Reputation: 7335
This is what I need in my node.js application:
This is what I found:
Do you have any recommendations? I need something reliable, easy to install and as cross-system as possible.
//edit
Since 6th November Appjs has basic tray icon support.
Upvotes: 18
Views: 20522
Reputation: 467
I've used systray on Linux. It is promised to work on macOS and Windows too. But I didn't tested it.
Example from official docs:
import SysTray from 'systray'
const systray = new SysTray({
menu: {
// you should using .png icon in macOS/Linux, but .ico format in windows
icon: "<base64 image 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()
}
})
It does not provide
creation of windows with fields for login / password and confirmation buttons
But this task is a separate one in my opinion. So this answer can be helpful for other people who just want systray icon.
Upvotes: 4
Reputation: 5761
For anyone else that lands up here, check out https://github.com/rogerwang/node-webkit - a great package that allows you to create desktop applications using your favourite tools like JavaScript, with support for native shell access, tray icons and a lot more.
Update: The app has moved to NWjs.io but it's the same brilliant concept.
Upvotes: 11
Reputation: 1612
Take a look at Node-QT (https://github.com/arturadib/node-qt) maybe that can help.
Upvotes: 3