Skip to content

Commit

Permalink
Support libayatana-appindicator on Linux
Browse files Browse the repository at this point in the history
This changes the default behavior to use libayatana-appindicator
instead of libappindicator. If you need to link to the older
libappindicator library, use the build tag "legacy_appindicator":

    go build -tags=legacy_appindicator

Closes #225, #224, and #191.
  • Loading branch information
Crosse committed Feb 23, 2022
1 parent 0984344 commit 73ea9ac
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,20 @@ The code under `webview_example` is to demostrate how it can co-exist with other

### Linux

* Building apps requires gcc as well as the `gtk3` and `libappindicator3` development headers to be installed. For Debian or Ubuntu, you may install these using:
* Building apps requires gcc as well as the `gtk3` and `libayatana-appindicator3` development headers to be installed. For Debian or Ubuntu, you may install these using:

```sh
sudo apt-get install gcc libgtk-3-dev libappindicator3-dev
sudo apt-get install gcc libgtk-3-dev libayatana-appindicator3-dev
```

On Linux Mint, `libxapp-dev` is also required .
On Linux Mint, `libxapp-dev` is also required.

If you need to support the older `libappindicator3` library instead, you can pass the build flag `legacy_appindicator`
when building. For example:

```
go build -tags=legacy_appindicator`
```

To build `webview_example`, you also need to install `libwebkit2gtk-4.0-dev` and remove `webview_example/rsrc.syso` which is required on Windows.

Expand Down
6 changes: 6 additions & 0 deletions systray_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
#include <string.h>
#include <errno.h>
#include <limits.h>

#ifdef USE_LEGACY_APPINDICATOR
#include <libappindicator/app-indicator.h>
#else
#include <libayatana-appindicator/app-indicator.h>
#endif

#include "systray.h"

static AppIndicator *global_app_indicator;
Expand Down
8 changes: 0 additions & 8 deletions systray_linux.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
package systray

/*
#cgo darwin CFLAGS: -DDARWIN -x objective-c -fobjc-arc
#cgo darwin LDFLAGS: -framework Cocoa -framework WebKit
#include "systray.h"
*/
import "C"

// SetTemplateIcon sets the systray icon as a template icon (on macOS), falling back
// to a regular icon on other platforms.
// templateIconBytes and iconBytes should be the content of .ico for windows and
Expand Down
11 changes: 11 additions & 0 deletions systray_linux_appindicator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build linux && legacy_appindicator

package systray

/*
#cgo linux pkg-config: appindicator3-0.1
#cgo linux CFLAGS: -DUSE_LEGACY_APPINDICATOR
#include "systray.h"
*/
import "C"
10 changes: 10 additions & 0 deletions systray_linux_ayatana.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build linux && !legacy_appindicator

package systray

/*
#cgo linux pkg-config: ayatana-appindicator3-0.1
#include "systray.h"
*/
import "C"

0 comments on commit 73ea9ac

Please sign in to comment.