wails
wails copied to clipboard
Support Tray Menus
Wails should support Tray Menus for all platforms. It should support the features appropriate to each platform, EG text for Mac, icons for all platforms, etc.
windows Tray(托盘)目前都没支持,非常不便
Any ideas on what would be the right mode of implementation?
e.g Should we start off with using a stable package or implement it ourselves @leaanthony ?
I mean in terms of contributing to the wails project?
Seeing this as a candidate for the library package dependency. https://github.com/getlantern/systray
Awesome that you'd like to contribute 🙏 Trays are literally the first cab off the rank post v2. There's some preliminary work in the exp
branch if you want to have a look. I fear Linux may be a no-go with it as it's likely to need a library installed on the client machine because the Gnome project don't believe it should be there 🙄
We would like to use this project (fantastic work btw) and have tray icon feature for the background workers for our cloud native ETL / data pipeline tool also written in Golang - https://github.com/dataplane-app/dataplane
@leaanthony When do you think this feature will be available?
Congratulations on releasing dataplane! Looks cool. There are never ETAs on features, however this feature is currently in-progress. There is a PR open with RFC here: https://github.com/wailsapp/wails/pull/1959. Is this time critical for you?
We were hoping to release in two weeks. We need the tray icon for basic open and exit a background process. I also want to show to users that it is running in the background. Is there any icon functionality available? I am not sure I need menus, just the icon to open and close the window. Once the window is open, we can then exit the app. To open the window, we can just click or double click the icon.
Multi platform tray icons will not be ready in 2 weeks unfortunately.
Will any platforms be available? We are focusing on Windows right now. Mac?
There's the PR I linked. That's where we are at.
Linux may be a no-go with it as it's likely to need a library installed on the client machine because the Gnome project don't believe it should be there roll_eyes
While it may require a library on Linux, I still think it's worth implementing something or at least giving a bit of boilerplate code to be able to have KStatusNotifierItem/AppIndicator support on Linux.
I understand you're working on Windows and Mac support first, but just wanted to put my vote in for Linux support, since we do have the capability of specifying dependencies, though maybe this is for dev only and not runtime? https://wails.io/docs/guides/linux-distro-support#adding-package-names
Thank you for the excellent project, and you have my sincerest gratitude for your effort!
Hi,
I think we could use Dbus with SystemNotifier/AppIndicator
as our main implementaion. It seems to me that it could solve the problem on a big portion of the most used distros without depending on any installed C library. For example fyne-io only supports the DBus way.
I tried this on a few distros:
- fedora latest (not working, default gnome)
- fedora KDE (works)
- kubuntu 22.04 (works)
- kubuntu 20.04 (works)
- ubuntu 22.04 gnome (works)
- popOS 22.04 gnome (works)
- linux mint cinnamon (works)
- linux mint xfce (works)
- linux mint mate (not working)
As a second option: If we want (have the time and determination to implement them) we could maybe hide the fallback implementations behind a build flag as an optional dependency?
And if the DBus way is not available fallback to libayatana-appindicator
and maybe libappindicator3
if its not available and throw a warning if neither is available. Tauri does the same thing. Electron simply depends on libappindicator1
. In the documentation we could inform the developers that the packaging and distribution of the libraries is their job.
I'm happy with this approach. If only linux had some common installer mechanism to make this easy 🤦

I don't know if anyone is "assigned" to the linux part of the tray pr #1959, if you'd like @leaanthony I could pick it up in mid November.
That would be amazing @Lyimmi Thank you! 🙏
There's this fork also https://github.com/fyne-io/systray. It claims to remove GTK deps. might be worth looking at. I tried it with a wails app I'm building and no issues on Ubuntu 22.04 (GNOME 42.5) so far. The app is still under development though
Yes, this is a Dbus implementation as well.
Currently I'm working on a background app, which should mostly sits in the tray. Are there plans, the WebView can actually be closed and re-started, instead of hide and show? To hide the WebView in such a scenario would be a waste of ressources.
Will be possible in v3 which has a much better API for such things 👍
I've found a better fork of systray
here, which supports left, right click and double (?) click: https://github.com/energye/systray
I've found a better fork of
systray
here, which supports left, right click and double (?) click: https://github.com/energye/systray
Used that before. Worked pretty well. 👍
I'm currently using it in a Wails project, it provides a much easier to use API and even extra click callbacks. Seamlessly integrates with Wails :)
I'm glad there's a workaround for v2. We will have native support in v3 (already working pretty well for Mac and Windows)
I'm currently using it in a Wails project, it provides a much easier to use API and even extra click callbacks. Seamlessly integrates with Wails :)
@lthon09 Would you mind giving me a glimpse on how you assembled the integration?
I'm glad there's a workaround for v2. We will have native support in v3 (already working pretty well for Mac and Windows)
@leaanthony I just stumbled upon a options.SystemTray
and options.SystemTrayIcon
with the help of intellisense. Is this fully implemented yet? I'm using v2.5.1.
@leaanthony I just stumbled upon a
options.SystemTray
andoptions.SystemTrayIcon
with the help of intellisense. Is this fully implemented yet? I'm using v2.5.1.
They were experiments. Ultimately, the v2 API is written specifically for single windows and that runs deep. I looked at adding it and it wasn't great so we've added it to v3 where the entire guts were built in a way to better support these features. A brave soul has made a project with it (even though it's alpha) and has screenshots here: https://github.com/duolabmeng6/go-qoq
I'm currently using it in a Wails project, it provides a much easier to use API and even extra click callbacks. Seamlessly integrates with Wails :)
@lthon09 Would you mind giving me a glimpse on how you assembled the integration?
It's just using some basic features of the package, create some menu items for showing and quitting the program. Here's some example code:
package main
import (
"github.com/energye/systray"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/runtime"
)
type _application struct {
context _context.Context
}
var __application *_application
func systemTray() {
systray.SetIcon([]byte()) // read the icon from a file
show := systray.AddMenuItem("Show", "Show The Window")
systray.AddSeparator()
exit := systray.AddMenuItem("Exit", "Quit The Program")
show.Click(func() {wailsRuntime.WindowShow(__application.context)})
exit.Click(func() {os.Exit(0)})
systray.SetOnClick(func() {wailsRuntime.WindowShow(__application.context)})
systray.SetOnRClick(func(menu systray.IMenu) {menu.ShowMenu()})
}
func main() {
__application = &_application{}
wails.Run(&options.App{
// ...
OnStartup: __application.startUp,
Bind: []interface{}{__application},
})
}
func (application *_application) startUp(context _context.Context) {
application.context = context
systray.Run(systemTray, func() {})
}
It integrates with Wails really well. Sorry if my code looks unclean!
Closing this as it's intended for v3 and there's no more work to be done on it.