17
votes

This is what I need in my node.js application:

  • System tray icon
  • changing this icon during application work
  • menu after clicking on icon
  • creation of windows with fields for login / password and confirmation buttons

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.

3
How did you solve this? I'm having almost the same use case, thinking of using now oldish node-qt.psp

3 Answers

11
votes

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.

3
votes

Take a look at Node-QT (https://github.com/arturadib/node-qt) maybe that can help.

2
votes

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.