gen2brain / beeep

Go cross-platform library for sending desktop notifications, alerts and beeps
BSD 2-Clause "Simplified" License
1.43k stars 89 forks source link

Add support for tray icons #26

Closed sampaioletti closed 5 years ago

sampaioletti commented 5 years ago

Just started using the library and I like how it has been written using pure go and syscalls. While there are cgo packages that handle system tray icons i haven't found one that uses syscalls and was thinking of trying it. Would it be within the scope of this project to add that in? If so I will start looking into it.

gen2brain commented 5 years ago

Systray icons are probably better to be in their own repo. Windows notifications currently use good library that can be used for that github.com/tadvi/systray.

For Linux, I don't think it is possible without CGO, usually, GTK+ or Qt is used there. I know there is pure/native lib for X11 https://github.com/BurntSushi/xgb, but not sure if that alone is enough to implement that, probably is, but for older standard.

And again, for macOS probably not possible without CGO.

srlehn commented 5 years ago

Here is a solution in C https://stackoverflow.com/a/45406723 which could be translated to xgb with Xembed(?) without the need for cgo.

Specs: https://specifications.freedesktop.org/systemtray-spec/systemtray-spec-0.3.html (old) https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/ (new) - this probably only needs dbus

gen2brain commented 5 years ago

Xembed is here https://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html, but not sure how is used in relation to systemtray-spec-0.3. It looks like that can work, in theory at least, together with StatusNotifier support and dbus.

Usually, you want to add some menu to tray icon, and then you will need some toolkit, or at least to draw controls with plain X, something like that. But just handling mouse events can also be useful I think.

sampaioletti commented 5 years ago

Ok sounds good, I was going to research it to see how possible it was, but this makes sense.

Thanks for the great repo!