Skip to content
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

[v2] MacOS New feature of tray menu. #1010

Closed
mostend opened this issue Dec 5, 2021 · 29 comments
Closed

[v2] MacOS New feature of tray menu. #1010

mostend opened this issue Dec 5, 2021 · 29 comments
Milestone

Comments

@mostend
Copy link

mostend commented Dec 5, 2021

Hi, I'm sorry to interrupt, but I've looked up a lot of information and I can't find.

I want to implement a feature where when the user clicks the close button, the program runs in the background and the small icon appears in the right menu bar.

@stffabi
Copy link
Collaborator

stffabi commented Dec 5, 2021

I think the option you are searching for might be 'HideWindowOnClose' https://wails.io/docs/reference/options#hidewindowonclose

Have you tried this option?

@leaanthony
Copy link
Member

I think they also want a tray menu. V2.1!

@mostend
Copy link
Author

mostend commented Dec 6, 2021

I think the option you are searching for might be 'HideWindowOnClose' https://wails.io/docs/reference/options#hidewindowonclose

Have you tried this option?

Yes, I have tried. but I found a issue. When closed and the program is running in the background, we have no way to show the main interface by clicking on the icon in the dock, only through other dialog.

@mostend
Copy link
Author

mostend commented Dec 6, 2021

I think they also want a tray menu. V2.1!

Do u have any plan? I think others need this feature as well, thank you very much for your reply.

@leaanthony
Copy link
Member

It's true, HideWindowOnClose is better with the tray feature. That'll come in v2.1.

@mostend mostend changed the title [v2] MacOS How to run in the background after clicking close? [v2] MacOS New feature of tary menu. Dec 7, 2021
@leaanthony leaanthony added v2.1 TODO The issue is ready to be developed labels Dec 7, 2021
@adrianlungu
Copy link

adrianlungu commented Feb 13, 2022

Is it possible to contribute to this in any way?

I was looking into making https://github.com/getlantern/systray work with Wails but, at least on MacOS, they both seem to import dependencies from the OS and thus make the linker complain about duplicate symbols i.e.

duplicate symbol 'OBJC_CLASS$_AppDelegate'

Even if there were a simple way to get past this, I think they both want to lock on to the main thread and thus other issues may arise.

So I've been thinking of adding the needed components directly into Wails and then figuring out a way to lock the main thread while still allowing both the systray and the main window to be able to use it (although it sounds like it might not be as easy as I imagine it to be)

@leaanthony
Copy link
Member

Running systray and Wails together is basically impossible. Tray support is coming right after be release. If you want to contribute you can look at how this works on Linux.

@leaanthony leaanthony added this to the v2.1.0 milestone Mar 6, 2022
@leaanthony leaanthony changed the title [v2] MacOS New feature of tary menu. [v2] MacOS New feature of tray menu. Mar 6, 2022
@TheFranconianCoder
Copy link

Running systray and Wails together is basically impossible. Tray support is coming right after be release. If you want to contribute you can look at how this works on Linux.

So I do the impossible. :-D Actually currently using a tray menu library together with Wails. Even run Wails only ad-hoc and close it (not hide). I'm sure it's all just a hack. But it works so far quite good.

@leaanthony
Copy link
Member

You're running 2 different processes for sure 😉

@TheFranconianCoder
Copy link

TheFranconianCoder commented Mar 6, 2022

I'm still learning about how Wails work. For my simple app I made a main package only for binding (I don't use any bindings, btw) and a second with my main app. This app runs mostly in background sitting in the tray additionally. Through the tray menu I can open a Wails window, which only starts wails.Run() in a goroutine. The window (it's frameless) is closed via the runtime API.

I also had another setup, where I only used show and hide of the Wails window. But since the process is mostly only in the background, you can save the ressources of the WebView.

To make that possible, I had to reset the flags before running wails. Or you will get errors of already defined flags.

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wont fix This will not be worked on label Apr 16, 2022
@stale stale bot closed this as completed Apr 28, 2022
@leaanthony leaanthony removed the wont fix This will not be worked on label Apr 30, 2022
@leaanthony leaanthony reopened this Jun 14, 2022
@leaanthony leaanthony removed the v2.1 label Jun 14, 2022
@leaanthony leaanthony removed the TODO The issue is ready to be developed label Jul 3, 2022
@leaanthony
Copy link
Member

This issue is a mixture of requests. Closing in favour of #1521

@dvx
Copy link

dvx commented Sep 28, 2022

I'm still learning about how Wails work. For my simple app I made a main package only for binding (I don't use any bindings, btw) and a second with my main app. This app runs mostly in background sitting in the tray additionally. Through the tray menu I can open a Wails window, which only starts wails.Run() in a goroutine. The window (it's frameless) is closed via the runtime API.

I also had another setup, where I only used show and hide of the Wails window. But since the process is mostly only in the background, you can save the ressources of the WebView.

To make that possible, I had to reset the flags before running wails. Or you will get errors of already defined flags.

Heya @sebastian0x62 -- I need this feature and don't mind being a bit hacky (even if running two processes) -- how exactly are you getting getlantern/systray to work with wails v2? I can't seem to get it to work.

@TheFranconianCoder
Copy link

Hey @dvx, Still looking for a solution? I switched from web-based for Desktop development to Flutter. So I'm no longer actively looking into Wails and similar. I still have a tiny demo project for this systray thing.

@TheFranconianCoder
Copy link

@dvx, tried to send you the demo via mail. GMail didn't like the attachment. You can find the project for download for two weeks: https://drive.proton.me/urls/WAH0Z5PZCR#NnZZDxHndOGS

@dvx
Copy link

dvx commented Oct 3, 2022

Thanks @sebastian0x62 -- got it! 🙏

@Issues-translate-bot
Copy link

The issue body's language is not English, translating it automatically...


Thanks @sebastian0x62 -- got it! 🙏

@leaanthony
Copy link
Member

Turns out you can run getlantern/systray with Wails by running it in a goroutine. However, I find systray limited and have got a WIP that already supports proper shutdown and automatic dark/light mode icon switching. More to come 👍

@dvx
Copy link

dvx commented Oct 3, 2022

@leaanthony I couldn't get the wails app to build (even with getlantern/systray in a goroutine) on my M1 (it weirdly hangs). I've been following the #feature/1521 branch and will probably wait for the official solution, seems like it's quite close as-is.

Thanks for your work! 🙏

@leaanthony
Copy link
Member

You're right, the way the Mac system tray works is a bit different than Windows, which will allow you to run it in a goroutine.

@ulixcode-labs
Copy link

Any update of this requests?

@mostend
Copy link
Author

mostend commented Jul 6, 2023

I'm trying the alpha version of V3, so far systray is working fine.

@leaanthony
Copy link
Member

@mostend - just be aware it's still in development and there's no API guarantees at this stage. That being said, there's a really awesome feature that's almost done and I think after that it will probably be stable 👍

@raffolgo
Copy link

@dvx, tried to send you the demo via mail. GMail didn't like the attachment. You can find the project for download for two weeks: https://drive.proton.me/urls/WAH0Z5PZCR#NnZZDxHndOGS

Hello ! I am also interested by making a systray on my mac OS app, can you resend me the link please ?

@ysaakpr
Copy link

ysaakpr commented Nov 17, 2023

Any way to add the icon to Top right corner menubar?

Part of this section
Screenshot 2023-11-17 at 8 09 42 PM

Edit:
May be its out of the scope, Looks like the possibilities are only by making widgets.

@munjalpatel
Copy link

@leaanthony Wails is awesome! Any updates on v3 ETA? I really need systray and trying to avoid hacks, if possible.

@edosssa
Copy link

edosssa commented Feb 24, 2024

+1

@leaanthony
Copy link
Member

Feel free to try out the alpha and see if it works for you: https://v3alpha.wails.io

@edosssa
Copy link

edosssa commented Feb 24, 2024

Thanks @leaanthony, will check it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests