[GH-ISSUE #101] Tray Support #62

Closed
opened 2026-05-05 11:35:52 -06:00 by gitea-mirror · 25 comments
Owner

Originally created by @JackPyro on GitHub (May 4, 2018).
Original GitHub issue: https://github.com/kusti8/proton-native/issues/101

Is Tray supported or gonna be supported in future versions?

Originally created by @JackPyro on GitHub (May 4, 2018). Original GitHub issue: https://github.com/kusti8/proton-native/issues/101 Is Tray supported or gonna be supported in future versions?
gitea-mirror 2026-05-05 11:35:52 -06:00
Author
Owner

@parro-it commented on GitHub (May 4, 2018):

Actually libui-node does not support them, because they are not implemented in libui (see this issue there: https://github.com/andlabs/libui/issues/216).

You can try to 👍🏻 that issue to get them implemented there.
Or alternatively, we can use other existing npm packages to implement it?
@kusti8 any thoughts?

<!-- gh-comment-id:386549043 --> @parro-it commented on GitHub (May 4, 2018): Actually [libui-node](https://github.com/parro-it/libui-node) does not support them, because they are not implemented in [libui](https://github.com/andlabs/libui) (see this issue there: https://github.com/andlabs/libui/issues/216). You can try to 👍🏻 that issue to get them implemented there. Or alternatively, we can use other existing npm packages to implement it? @kusti8 any thoughts?
Author
Owner

@kusti8 commented on GitHub (May 4, 2018):

I don't think working with other node packages is going to work that well. I looked quickly and there doesn't seem to be anything cross platform and I assume all the solutions have their own blocking event loop and implementation into JSX is going to be non trivial.

<!-- gh-comment-id:386573062 --> @kusti8 commented on GitHub (May 4, 2018): I don't think working with other node packages is going to work that well. I looked quickly and there doesn't seem to be anything cross platform and I assume all the solutions have their own blocking event loop and implementation into JSX is going to be non trivial.
Author
Owner

@parro-it commented on GitHub (May 4, 2018):

I looked quickly and there doesn't seem to be anything cross platform and I assume all the solutions have their own blocking event loop and implementation into JSX is going to be non trivial.

If libui does not want to implement it, I could write a new package that leverage the event loop of libui-node

<!-- gh-comment-id:386573605 --> @parro-it commented on GitHub (May 4, 2018): > I looked quickly and there doesn't seem to be anything cross platform and I assume all the solutions have their own blocking event loop and implementation into JSX is going to be non trivial. If `libui` does not want to implement it, I could write a new package that leverage the event loop of libui-node
Author
Owner

@kusti8 commented on GitHub (May 4, 2018):

I don't think that would be that good and it could get out of hand quickly. @JackPyro what exactly do you mean by tray? There's this https://github.com/mikaelbr/node-notifier which can send notifications. But if you want a tray icon it doesn't seem like there's anything good that works.

<!-- gh-comment-id:386582089 --> @kusti8 commented on GitHub (May 4, 2018): I don't think that would be that good and it could get out of hand quickly. @JackPyro what exactly do you mean by tray? There's this https://github.com/mikaelbr/node-notifier which can send notifications. But if you want a tray icon it doesn't seem like there's anything good that works.
Author
Owner

@thormengkheang commented on GitHub (May 10, 2018):

Would be nice if it has system tray support

<!-- gh-comment-id:387941693 --> @thormengkheang commented on GitHub (May 10, 2018): Would be nice if it has system tray support
Author
Owner

@JackPyro commented on GitHub (May 10, 2018):

@kusti8 More like this:
image

I've got my answer, so feel free to close this issue.

<!-- gh-comment-id:388148589 --> @JackPyro commented on GitHub (May 10, 2018): @kusti8 More like this: ![image](https://user-images.githubusercontent.com/5402106/39887690-87a0ca88-549b-11e8-9da5-58558a68f293.png) I've got my answer, so feel free to close this issue.
Author
Owner

@Darkle commented on GitHub (Jun 5, 2018):

What about using https://github.com/zaaack/node-systray?

<!-- gh-comment-id:394667046 --> @Darkle commented on GitHub (Jun 5, 2018): What about using https://github.com/zaaack/node-systray?
Author
Owner

@parro-it commented on GitHub (Jun 5, 2018):

What about using https://github.com/zaaack/node-systray?

Seems nice

<!-- gh-comment-id:394667392 --> @parro-it commented on GitHub (Jun 5, 2018): > What about using https://github.com/zaaack/node-systray? Seems nice
Author
Owner

@parro-it commented on GitHub (Jun 5, 2018):

But there's not C++ code, neither C, how could it work?

<!-- gh-comment-id:394668382 --> @parro-it commented on GitHub (Jun 5, 2018): But there's not C++ code, neither C, how could it work?
Author
Owner

@kusti8 commented on GitHub (Jun 5, 2018):

Seems like it uses https://github.com/zaaack/systray-portable which is Go
code.

On Tue, Jun 5, 2018, 7:01 AM Andrea Parodi notifications@github.com wrote:

But there's not C++ code, neither C, how could it work?


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/kusti8/proton-native/issues/101#issuecomment-394668382,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AJW73Hiaymuu6SHgH8XNQLbOKFAQndXHks5t5mUZgaJpZM4TyV7S
.

<!-- gh-comment-id:394668870 --> @kusti8 commented on GitHub (Jun 5, 2018): Seems like it uses https://github.com/zaaack/systray-portable which is Go code. On Tue, Jun 5, 2018, 7:01 AM Andrea Parodi <notifications@github.com> wrote: > But there's not C++ code, neither C, how could it work? > > — > You are receiving this because you were mentioned. > > > Reply to this email directly, view it on GitHub > <https://github.com/kusti8/proton-native/issues/101#issuecomment-394668382>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AJW73Hiaymuu6SHgH8XNQLbOKFAQndXHks5t5mUZgaJpZM4TyV7S> > . >
Author
Owner

@parro-it commented on GitHub (Jun 5, 2018):

ah ok not it make sense

<!-- gh-comment-id:394669292 --> @parro-it commented on GitHub (Jun 5, 2018): ah ok not it make sense
Author
Owner

@Darkle commented on GitHub (Jun 5, 2018):

https://github.com/zaaack/systray-portable seems to include precompiled binaries for each OS though. Would it be possible to include the binary when libui is compiled?

<!-- gh-comment-id:394669764 --> @Darkle commented on GitHub (Jun 5, 2018): https://github.com/zaaack/systray-portable seems to include precompiled binaries for each OS though. Would it be possible to include the binary when libui is compiled?
Author
Owner

@parro-it commented on GitHub (Jun 5, 2018):

@Darkle, if you mean in libui-node:

Actually libui-node does not support them, because they are not implemented in libui (see this issue there: andlabs/libui#216).

libui-node is and will remain only a binding library to what libui implements. But what's wrong using systray-portable directly in app code?

<!-- gh-comment-id:394671527 --> @parro-it commented on GitHub (Jun 5, 2018): @Darkle, if you mean in libui-node: > Actually libui-node does not support them, because they are not implemented in libui (see this issue there: andlabs/libui#216). libui-node is and will remain only a binding library to what libui implements. But what's wrong using systray-portable directly in app code?
Author
Owner

@kusti8 commented on GitHub (Jun 5, 2018):

Once you get down the road of adding random binaries to stuff like libui-node or proton native, it gets to be a mess, not just because you have to manage one more build scheme, but also because you end up bloating it with people asking why not this binary also.

I'll make a page in the docs to address third party solutions such as this, but they should be separate.

<!-- gh-comment-id:394672191 --> @kusti8 commented on GitHub (Jun 5, 2018): Once you get down the road of adding random binaries to stuff like libui-node or proton native, it gets to be a mess, not just because you have to manage one more build scheme, but also because you end up bloating it with people asking why not this binary also. I'll make a page in the docs to address third party solutions such as this, but they should be separate.
Author
Owner

@parro-it commented on GitHub (Jun 5, 2018):

I'll make a page in the docs to address third party solutions such as this, but they should be separate.

We should start an awesome-desktop-js list...

<!-- gh-comment-id:394683258 --> @parro-it commented on GitHub (Jun 5, 2018): > I'll make a page in the docs to address third party solutions such as this, but they should be separate. We should start an awesome-desktop-js list...
Author
Owner
<!-- gh-comment-id:394684285 --> @Darkle commented on GitHub (Jun 5, 2018): > We should start an awesome-desktop-js list... Here are some links I have stored in Evernote related to js and desktop app dev: - https://github.com/BrigJS/brig - Node exe packagers: - https://github.com/nexe/nexe - https://github.com/pmq20/node-packer - http://nectarjs.com/ - https://github.com/zeit/pkg - http://thecodebarbarian.com/standalone-express-apis-binaries-with-pkg.html - https://www.npmjs.com/package/lone - https://github.com/parro-it/libui-node - https://github.com/parro-it/libui-node/blob/master/docs/initialization.md - https://github.com/nacmartin/nodetcltk - https://github.com/trueinteractions/tint2 - https://github.com/joeferner/wxNode - https://github.com/sindresorhus/trayballoon - https://github.com/breach/thrust/ - https://news.ycombinator.com/item?id=8604716 - http://quaxe.org/ - https://livecode.com - https://github.com/HackPlan/quark-shell-mac - https://github.com/glennw/servo-shell - https://github.com/ocornut/imgui - https://github.com/pojala/electrino - https://github.com/WebReflection/jsgtk - https://github.com/Shouqun/node-skia - https://github.com/facebook/yoga - http://libyue.com/docs/latest/js/guides/getting_started.html - https://github.com/kusti8/proton-native (some might be a little old)
Author
Owner

@khanhas commented on GitHub (Jun 5, 2018):

Electron supports creating Tray menu out of the box.
Tray as well as toast notification are basic elements of what we calls "Apps" nowadays.
Using third-party package is fine but I think you guys should aim proton-native as a one-go solution to create a complete app.

<!-- gh-comment-id:394684804 --> @khanhas commented on GitHub (Jun 5, 2018): Electron supports creating Tray menu out of the box. Tray as well as toast notification are basic elements of what we calls "Apps" nowadays. Using third-party package is fine but I think you guys should aim proton-native as a one-go solution to create a complete app.
Author
Owner

@mischnic commented on GitHub (Jun 5, 2018):

Example for node-systray with proton-native:
The only glue code needed is calling the kill method from node-systray.

import React, { Component } from 'react';
import SysTray from 'systray';
import fs from "fs";

import { render, Window, App, Box, TextInput, Menu } from 'proton-native';

const systray = new SysTray({
    menu: {
        // you should using .png icon in macOS/Linux, but .ico format in windows
        icon: new Buffer(fs.readFileSync("/.../icon.png")).toString('base64'),
        title: "Test",
        tooltip: "Tips",
        items: [{
            title: "Item",
            tooltip: "Item Tooltip",
            enabled: true
        }, {
            title: "Exit",
            tooltip: "bb",
            enabled: true
        }]
    },
    debug: false,
    copyDir: true
})

systray.onClick(action => {
    if (action.seq_id === 0) {
      console.log("Hi!");
    } else if (action.seq_id === 1) {
      systray.kill()
    }
});

const stop = ()=>{
  systray.kill(false)
};

class Example extends Component {
  render() {
    return (
      <App onShouldQuit={stop}>
        <Menu>
          <Menu.Item type="Quit"/>
        </Menu>
        <Window onClose={stop} title="Proton Native Rocks!" size={{w: 400, h: 400}} menuBar={false}>
            <Box>
            	<TextInput>Hi</TextInput>
            </Box>
        </Window>
      </App>
    );
  }
}

render(<Example />);

<!-- gh-comment-id:394686462 --> @mischnic commented on GitHub (Jun 5, 2018): Example for node-systray with proton-native: The only glue code needed is calling the `kill` method from node-systray. ```js import React, { Component } from 'react'; import SysTray from 'systray'; import fs from "fs"; import { render, Window, App, Box, TextInput, Menu } from 'proton-native'; const systray = new SysTray({ menu: { // you should using .png icon in macOS/Linux, but .ico format in windows icon: new Buffer(fs.readFileSync("/.../icon.png")).toString('base64'), title: "Test", tooltip: "Tips", items: [{ title: "Item", tooltip: "Item Tooltip", enabled: true }, { title: "Exit", tooltip: "bb", enabled: true }] }, debug: false, copyDir: true }) systray.onClick(action => { if (action.seq_id === 0) { console.log("Hi!"); } else if (action.seq_id === 1) { systray.kill() } }); const stop = ()=>{ systray.kill(false) }; class Example extends Component { render() { return ( <App onShouldQuit={stop}> <Menu> <Menu.Item type="Quit"/> </Menu> <Window onClose={stop} title="Proton Native Rocks!" size={{w: 400, h: 400}} menuBar={false}> <Box> <TextInput>Hi</TextInput> </Box> </Window> </App> ); } } render(<Example />); ```
Author
Owner

@styfle commented on GitHub (Jun 5, 2018):

@Darkle Do you mind if I make the awesome list starting with your notes?

<!-- gh-comment-id:394695587 --> @styfle commented on GitHub (Jun 5, 2018): @Darkle Do you mind if I make the awesome list starting with your notes?
Author
Owner

@Darkle commented on GitHub (Jun 5, 2018):

@styfle Yeah sure thing.

<!-- gh-comment-id:394696339 --> @Darkle commented on GitHub (Jun 5, 2018): @styfle Yeah sure thing.
Author
Owner

@parro-it commented on GitHub (Jun 5, 2018):

@styfle I also have a gist where I collected link, articles and interesting snippets of code, mainly about libuv and GUI event loops https://gist.github.com/parro-it/842ff46a86142c30b1f94f97bb738418.
Really caotic, but something could be useful...

<!-- gh-comment-id:394805945 --> @parro-it commented on GitHub (Jun 5, 2018): @styfle I also have a gist where I collected link, articles and interesting snippets of code, mainly about libuv and GUI event loops https://gist.github.com/parro-it/842ff46a86142c30b1f94f97bb738418. Really caotic, but something could be useful...
Author
Owner

@Darkle commented on GitHub (Jun 5, 2018):

@mischnic re:
https://zaaack.github.io/node-systray/classes/index.systray.html#kill

const stop = ()=>{
  systray.kill(false)
};

Why would you kill systray here, but not the node process?

<!-- gh-comment-id:394883124 --> @Darkle commented on GitHub (Jun 5, 2018): @mischnic re: https://zaaack.github.io/node-systray/classes/_index_.systray.html#kill ``` const stop = ()=>{ systray.kill(false) }; ``` Why would you kill systray here, but not the node process?
Author
Owner

@kusti8 commented on GitHub (Jun 5, 2018):

@Darkle because this is called when the window or app is closed, so the node process is already stopping, so the last thing we need to stop is the systray. The event loop gets stopped when you have a last Window left or the app quits through Menu.

<!-- gh-comment-id:394883642 --> @kusti8 commented on GitHub (Jun 5, 2018): @Darkle because this is called when the window or app is closed, so the node process is already stopping, so the last thing we need to stop is the systray. The event loop gets stopped when you have a last Window left or the app quits through Menu.
Author
Owner

@Darkle commented on GitHub (Jun 5, 2018):

because this is called when the window or app is closed, so the node process is already stopping, so the last thing we need to stop is the systray. The event loop gets stopped when you have a last Window left or the app quits through Menu.

Ah ok. There might be some people that are expecting different behaviour though. It's fairly common for apps that have a system tray icon to remain open after you close their apps main window.

When you add info to the proton-native docs about this systray module, it might be a good idea to mention this as well, in case people expect their app to stick around after the window closes because of the systray icon.

<!-- gh-comment-id:394885219 --> @Darkle commented on GitHub (Jun 5, 2018): > because this is called when the window or app is closed, so the node process is already stopping, so the last thing we need to stop is the systray. The event loop gets stopped when you have a last Window left or the app quits through Menu. Ah ok. There might be some people that are expecting different behaviour though. It's fairly common for apps that have a system tray icon to remain open after you close their apps main window. When you add info to the proton-native docs about this systray module, it might be a good idea to mention this as well, in case people expect their app to stick around after the window closes because of the systray icon.
Author
Owner

@styfle commented on GitHub (Jun 6, 2018):

@Darkle @parro-it I got a list started here: https://github.com/styfle/awesome-desktop-js

Feel free to send a PR 👍

<!-- gh-comment-id:395069628 --> @styfle commented on GitHub (Jun 6, 2018): @Darkle @parro-it I got a list started here: https://github.com/styfle/awesome-desktop-js Feel free to send a PR 👍
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/proton-native#62
No description provided.