Skip to content

Commit

Permalink
Update docs with some more API hints and helpful projects.
Browse files Browse the repository at this point in the history
Fixes #30
  • Loading branch information
andydotxyz committed Nov 29, 2022
1 parent d16a617 commit 3cfcb36
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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!
Expand All @@ -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:
Expand All @@ -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
<!-- avoid having a blurry icon and text -->
<!-- avoid having a blurry icon and text -->
<key>NSHighResolutionCapable</key>
<string>True</string>

Expand Down
Binary file modified example/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3cfcb36

Please sign in to comment.