godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.17k stars 98 forks source link

Add support for OS system tray to allow closing/minimizing exported projects to the tray #2349

Open gabrielborgesweb opened 3 years ago

gabrielborgesweb commented 3 years ago

Run exported as system tray, with (or without) script.

Describe the project you are working on

Well, I was thinking about my future project, where it will be a multiplayer game and along with the game there will be advanced systems like native auto-update and out-of-game notifications ("Match Found!", for example).

Describe the problem or limitation you are having in your project

But, one of those features have a engine limitation for now. This feature is out-of-game notifications. It needs to be another .EXE and running as System Tray.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It would be nice, when exporting the project for Windows, MacOS or Linux, an option that runs the program on the System Tray and define some functions if the user opens the Context Menu on the icon. With that, we can make some popups using custom GUI. (Concept below) image

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Concepts:

godotSystemTray

The operation will be as follows: There will be a PoolStringArray to be able to define functions in the Context Menu. godotSystemTrayExport Syntax: (OPTION_TITLE : String, GDSCRIPT : String)

If this enhancement will not be used often, can it be worked around with a few lines of script?

If by any chance, this cannot be done visually on Export window, you can use the following GDScript commands: OS.on_system_tray(true); OS.system_tray_context(INDEX : int, OPTION_TITLE : String, GDSCRIPT : String)

Is there a reason why this should be core and not an add-on in the asset library?

Well, from what I know about programming, unfortunately that will not be possible as a plugin/add-on in the Asset Library, for perhaps being very complex.

YuriSizov commented 3 years ago

Please follow the proposal template and provide all required information for your proposal to be considered.

gabrielborgesweb commented 3 years ago

Please follow the proposal template and provide all required information for your proposal to be considered.

Ok, updating...

Calinou commented 3 years ago

As this feature's implementation is highly OS-specific and not relevant to most games, I would recommend you to use a third-party utility like RBTray instead. It lets you minimize any application to the system tray by right-clicking the Minimize button.

Also, automatic updates and matchmaking features are generally better provided by third-party services such as Steam and itch.io.

YuriSizov commented 3 years ago

Please follow the proposal template and provide all required information for your proposal to be considered.

Ok, updating...

Thank you, but I think you've removed all the section titles and as a result you don't have sections and everything is bold.

gabrielborgesweb commented 3 years ago

Please follow the proposal template and provide all required information for your proposal to be considered.

Ok, updating...

Thank you, but I think you've removed all the section titles and as a result you don't have sections and everything is bold.

It happens because of ### on each paragraph. Updating again...

jespereggers commented 3 years ago

any updates on this? This is not "unimportant to most games" but incredibly relevant to many devs out there. No matter if it's for games or not (Godot isn't just good for making games btw)

jespereggers commented 3 years ago
Calinou commented 3 years ago

any updates on this? This is not "unimportant to most games" but incredibly relevant to many devs out there. No matter if it's for games or not (Godot isn't just good for making games btw)

As far as I know, nobody has started working on this feature yet. This proposal hasn't received much support, so it may not be implemented at all in core. However, it's always feasible for a skilled developer to implement this in a fork of Godot, for those who really need it.

  • Engines like Unity, UE, CryEngine & GameMaker support notifications as well...

Sending desktop notifications is covered by https://github.com/godotengine/godot-proposals/issues/1338. That proposal has received more support because it's more wildly applicable – games might actually need to send desktop notifications from time to time.

PS: Please use the Edit button (hidden behind the icon at the top-right corner of your comments) instead of multi-posting.

CsloudX commented 3 years ago

I like this feature too, and I wish I can hide taskbar icon, like DesktopPet App. Or OS-specific plugins, implement common useful features.

shrewdlogarithm commented 3 years ago

I'll add my 10p to this - I've recently found myself using Godot to create simple GUI apps and they would benefit from being 'Minimize to Tray' capable

It's also not a 100% Windows thing - when I previously used nwjs it supported this concept on MacOS and some Linux Desktops too - docs here if anyone's interested

https://docs.nwjs.io/en/latest/References/Tray/

Bauxitedev commented 3 years ago

If you're using godot-rust you can use this crate to make a tray icon on Win/Mac/Linux: https://github.com/olback/tray-item-rs

shrewdlogarithm commented 3 years ago

If you're using godot-rust you can use this crate to make a tray icon on Win/Mac/Linux: https://github.com/olback/tray-item-rs

Thats interesting and useful to know - thanks!

fire commented 2 years ago

https://github.com/dmikushin/tray Found a single header, super tiny C99 implementation of a system tray icon with a popup menu.on Github.

Edited: Changed link to the fork.

Calinou commented 2 years ago

zserge/tray Found a single header, super tiny C99 implementation of a system tray icon with a popup menu.on Github.

The upstream repository doesn't appear to be actively maintained, so I'd recommend using the fork instead.

maxeonyx commented 2 years ago

I'm interested in using this feature for my multiplayer game, for which I've made a separate "dedicated server" GUI scene export, which is something that will tend to run in the background.

BadCoyoteStudios commented 2 years ago

I'm writing an app right now that could use this functionality. If Godot is going to be used for applications or advanced games, functionality like this will really help. In the meantime, I may have to move to MAUI.

FeralBytes commented 1 year ago

It would be nice if this tiny library could be included in core: https://github.com/dmikushin/tray and can @Calinou as a contributor to RBTray, can you confirm that is a Windows specific tool? I am hoping to create minimize to tray functionality for a parental tool/Firewall manager on my children's Linux systems.

Calinou commented 1 year ago

and can @Calinou as a contributor to RBTray, can you confirm that is a Windows specific tool?

RBTray is Windows-only, but it's likely feasible to create an alternative that works on macOS and Linux too.

OsakiTsukiko commented 1 year ago

this would also be very useful for making launchers for games using godot, once the main game launches the launcher can go to tray and maybe have the ability to add a few options to it like quit, stop, etc

Lance-Starkie commented 1 year ago

Yeah, I've got this same issue, for a project I'm working on, would be very nice for a window manager, as playing hot potato whenever the main window gets closed seems like a nightmare to implement. Being able to just retire it to the taskbar is a really nice clean solution there.

foxp552 commented 3 months ago

any updates on this? This is not "unimportant to most games" but incredibly relevant to many devs out there. No matter if it's for games or not (Godot isn't just good for making games btw)

Same bro✋🥲 (Im not an developer btw)🥲

Calinou commented 3 months ago

@foxp552 Please don't bump issues without contributing significant new information. Use the :+1: reaction button on the first post instead.

Also, if I'm reading the documentation right, this is already implemented in 4.3 on Windows and macOS, but not on Linux. You'll need to use a StatusIndicator node (e.g. as the root node of an autoloaded scene) and a native menu that can be a PopupMenu child with prefer_native_menu set to true. Make sure to assign the PopupMenu node in the StatusIndicator's popup property afterwards, and it should appear when clicking the tray icon.

I'll look into expanding the Operating System Testing demo to add an example.

Adding Linux support will prove challenging, as the pull request says:

  • Linux (org.freedesktop.StatusNotifierItem/org.kde.StatusNotifierItem on D-BUS) Interface seems to be tied to specific GUI kit menus and external icon resources, so will keep it Windows/macOS only for now.

(Godot does not link against GTK, Qt or any other GUI toolkit.)

foxp552 commented 3 months ago

@Calinou Yes sir |(0_0)\ By the way im still new to these staff

unfa commented 3 months ago

Ok, I love that this works, even if not on Linux (yet). I wish there was a way to make the application skip taskbar when a status indicator is present. I am making a productivity application that is supposed to be always on-screen, and having it occupy the taskbar is unnecessary clutter - keeping it to the status icon only would be preferable. Do you consider that a related feature?

Calinou commented 3 months ago

I am making a productivity application that is supposed to be always on-screen, and having it occupy the taskbar is unnecessary clutter - keeping it to the status icon only would be preferable. Do you consider that a related feature?

There's a proposal tracking this: https://github.com/godotengine/godot-proposals/issues/8467