-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Tray Menus (Windows) #1521
Comments
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 |
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: #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. |
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 I tried this on a few distros:
As a second option: And if the DBus way is not available fallback to |
I'm happy with this approach. If only linux had some common installer mechanism to make this easy 🤦 |
https://xkcd.com/927
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. |
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 |
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) |
@lthon09 Would you mind giving me a glimpse on how you assembled the integration?
@leaanthony I just stumbled upon a |
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 |
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. |
The above doesn't work as wails and energye/systray both have an AppDelegate on MacOS and it results in a linker error (see below). Were you able to get it working on Mac?
|
Unfortunately no I haven't tried anything on Mac and this code was from really long ago. |
This fork contains the modification you wanted. It's not released though, so perhaps you want to add it to your project's submodule and replace the go module with it git submodule add https://github.com/fyne-io/systray.git systray
echo 'replace fyne.io/systray => ./systray' >> go.mod |
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.
Other Platforms:
The text was updated successfully, but these errors were encountered: