diff --git a/README.md b/README.md index e6b22576..b174f33c 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,27 @@ func onExit() { } ``` +### Running in a Fyne app + +This repository is designed to allow any toolkit to integrate system tray without any additional dependencies. +It is maintained by the Fyne team, but if you are using Fyne there is an even easier to use API in the main repository that wraps this project. + +In your app you can use a standard `fyne.Menu` structure and pass it to `SetSystemTrayMenu` when your app is a desktop app, as follows: + +```go + menu := fyne.NewMenu("MyApp", + fyne.NewMenuItem("Show", func() { + log.Println("Tapped show") + })) + + if desk, ok := myApp.(desktop.App); ok { + desk.SetSystemTrayMenu(menu) + } +``` + +You can find out more in the toolkit documentation: +[System Tray Menu](https://developer.fyne.io/explore/systray). + ### Run in another toolkit Most graphical toolkits will grab the main loop so the `Run` code above is not possible. @@ -50,26 +71,18 @@ Note: this package requires cgo, so make sure you set `CGO_ENABLED=1` before bui ## Try the example app! -Have go v1.12+ or higher installed? Here's an example to get started on macOS: +Have go v1.12+ or higher installed? Here's an example to get started on macOS or Linux: ```sh git clone https://github.com/fyne-io/systray cd systray/example -env GO111MODULE=on go build -./example +go run . ``` -On Windows, you should build like this: +On Windows, you should follow the instructions above, but use the followign run command: ``` -env GO111MODULE=on go build -ldflags "-H=windowsgui" -``` - -The following text will then appear on the console: - - -```sh -go: finding github.com/fyne-io/systray latest +go run -ldflags "-H=windowsgui" . ``` Now look for *Awesome App* in your menu bar! @@ -82,6 +95,10 @@ Now look for *Awesome App* in your menu bar! This implementation uses DBus to communicate through the SystemNotifier/AppIndicator spec, older tray implementations may not load the icon. +If you are running an older desktop environment, or system tray provider, you may require a proxy app which can convert the new DBus calls to the old format. +The recommended tool for Gnome based trays is [snixembed](https://git.sr.ht/~steef/snixembed), others are available. +Search for "StatusNotifierItems XEmbedded" in your package manager. + ### Windows * To avoid opening a console at application startup, use "fyne package" for your app or manually use these compile flags: @@ -104,10 +121,10 @@ SystrayApp.app/ SystrayApp.icns ``` -When running as an app bundle, you may want to add one or both of the following to your Info.plist: +If bundling manually, you may want to add one or both of the following to your Info.plist: ```xml - + NSHighResolutionCapable True diff --git a/example/screenshot.png b/example/screenshot.png index fb3ab91d..a29fdb55 100644 Binary files a/example/screenshot.png and b/example/screenshot.png differ