Skip to content

Commit 73ea9ac

Browse files
committed
Support libayatana-appindicator on Linux
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.
1 parent 0984344 commit 73ea9ac

5 files changed

+37
-11
lines changed

README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,20 @@ The code under `webview_example` is to demostrate how it can co-exist with other
7070

7171
### Linux
7272

73-
* 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:
73+
* 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:
7474

7575
```sh
76-
sudo apt-get install gcc libgtk-3-dev libappindicator3-dev
76+
sudo apt-get install gcc libgtk-3-dev libayatana-appindicator3-dev
7777
```
7878

79-
On Linux Mint, `libxapp-dev` is also required .
79+
On Linux Mint, `libxapp-dev` is also required.
80+
81+
If you need to support the older `libappindicator3` library instead, you can pass the build flag `legacy_appindicator`
82+
when building. For example:
83+
84+
```
85+
go build -tags=legacy_appindicator`
86+
```
8087

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

systray_linux.c

+6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
#include <string.h>
33
#include <errno.h>
44
#include <limits.h>
5+
6+
#ifdef USE_LEGACY_APPINDICATOR
57
#include <libappindicator/app-indicator.h>
8+
#else
9+
#include <libayatana-appindicator/app-indicator.h>
10+
#endif
11+
612
#include "systray.h"
713

814
static AppIndicator *global_app_indicator;

systray_linux.go

-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
package systray
22

3-
/*
4-
#cgo darwin CFLAGS: -DDARWIN -x objective-c -fobjc-arc
5-
#cgo darwin LDFLAGS: -framework Cocoa -framework WebKit
6-
7-
#include "systray.h"
8-
*/
9-
import "C"
10-
113
// SetTemplateIcon sets the systray icon as a template icon (on macOS), falling back
124
// to a regular icon on other platforms.
135
// templateIconBytes and iconBytes should be the content of .ico for windows and

systray_linux_appindicator.go

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//go:build linux && legacy_appindicator
2+
3+
package systray
4+
5+
/*
6+
#cgo linux pkg-config: appindicator3-0.1
7+
#cgo linux CFLAGS: -DUSE_LEGACY_APPINDICATOR
8+
9+
#include "systray.h"
10+
*/
11+
import "C"

systray_linux_ayatana.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build linux && !legacy_appindicator
2+
3+
package systray
4+
5+
/*
6+
#cgo linux pkg-config: ayatana-appindicator3-0.1
7+
8+
#include "systray.h"
9+
*/
10+
import "C"

0 commit comments

Comments
 (0)