Skip to content

Commit d3be8af

Browse files
committed
Merge branch 'main' into develop
2 parents 85db5c7 + 7a15e92 commit d3be8af

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
# integrations-linux
2-
Linux-specific implemenations of the integrations-api
2+
Linux-specific implemenations of the [integrations-api](https://github.com/cryptomator/integrations-api).
3+
4+
# Config
5+
6+
This project uses the following JVM properties:
7+
* `cryptomator.integrationsLinux.trayIconsDir` - specifies the directory from which svg images for the tray icon are loaded
8+

pom.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>org.cryptomator</groupId>
77
<artifactId>integrations-linux</artifactId>
8-
<version>1.3.0-SNAPSHOT</version>
8+
<version>1.4.0-SNAPSHOT</version>
99

1010
<name>integrations-linux</name>
1111
<description>Provides optional Linux services used by Cryptomator</description>
@@ -40,10 +40,10 @@
4040

4141
<!-- runtime dependencies -->
4242

43-
<api.version>1.3.0-beta1</api.version>
43+
<api.version>1.3.0</api.version>
4444
<secret-service.version>1.8.1-jdk17</secret-service.version>
4545
<kdewallet.version>1.3.2</kdewallet.version>
46-
<appindicator.version>1.3.0</appindicator.version>
46+
<appindicator.version>1.3.4</appindicator.version>
4747
<guava.version>32.0.0-jre</guava.version>
4848
<slf4j.version>1.7.36</slf4j.version>
4949
<commons-lang3.version>3.12.0</commons-lang3.version>
@@ -91,8 +91,7 @@
9191
<!-- Java bindings for appindicator -->
9292
<dependency>
9393
<groupId>org.purejava</groupId>
94-
<artifactId>appindicator-gtk3-java</artifactId>
95-
<classifier>libayatana-appindicator-libappindicator-minimal</classifier>
94+
<artifactId>libappindicator-gtk3-java-minimal</artifactId>
9695
<version>${appindicator.version}</version>
9796
</dependency>
9897
<dependency>

src/main/java/org/cryptomator/linux/tray/AppindicatorTrayMenuController.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.cryptomator.linux.tray;
22

3+
import org.apache.commons.lang3.StringUtils;
34
import org.cryptomator.integrations.common.CheckAvailability;
45
import org.cryptomator.integrations.common.OperatingSystem;
56
import org.cryptomator.integrations.common.Priority;
@@ -11,29 +12,32 @@
1112
import org.cryptomator.integrations.tray.TrayMenuException;
1213
import org.cryptomator.integrations.tray.TrayMenuItem;
1314
import org.purejava.appindicator.GCallback;
14-
import org.purejava.appindicator.MemoryAllocator;
15+
import org.purejava.appindicator.NativeLibUtilities;
1516

1617
import java.lang.foreign.Arena;
1718
import java.lang.foreign.MemorySegment;
1819
import java.lang.foreign.SegmentScope;
1920
import java.util.List;
21+
import java.util.Optional;
2022
import java.util.function.Consumer;
2123

2224
import static org.purejava.appindicator.app_indicator_h.*;
2325

2426
@Priority(1000)
27+
@CheckAvailability
2528
@OperatingSystem(OperatingSystem.Value.LINUX)
2629
public class AppindicatorTrayMenuController implements TrayMenuController {
27-
2830
private static final String APP_INDICATOR_ID = "org.cryptomator.Cryptomator";
31+
private static final String SVG_SOURCE_PROPERTY = "cryptomator.integrationsLinux.trayIconsDir";
2932

3033
private static final SegmentScope SCOPE = SegmentScope.global();
3134
private MemorySegment indicator;
3235
private MemorySegment menu = gtk_menu_new();
36+
private Optional<String> svgSourcePath;
3337

3438
@CheckAvailability
3539
public static boolean isAvailable() {
36-
return MemoryAllocator.isLoadedNativeLib();
40+
return NativeLibUtilities.isLoadedNativeLib();
3741
}
3842

3943
@Override
@@ -46,9 +50,20 @@ public void showTrayIcon(Consumer<TrayIconLoader> iconLoader, Runnable runnable,
4650

4751
private void showTrayIconWithSVG(String s) {
4852
try (var arena = Arena.openConfined()) {
49-
indicator = app_indicator_new(arena.allocateUtf8String(APP_INDICATOR_ID),
50-
arena.allocateUtf8String(s),
51-
APP_INDICATOR_CATEGORY_APPLICATION_STATUS());
53+
svgSourcePath = Optional.ofNullable(System.getProperty(SVG_SOURCE_PROPERTY));
54+
// flatpak
55+
if (svgSourcePath.isEmpty()) {
56+
indicator = app_indicator_new(arena.allocateUtf8String(APP_INDICATOR_ID),
57+
arena.allocateUtf8String(s),
58+
APP_INDICATOR_CATEGORY_APPLICATION_STATUS());
59+
// AppImage and ppa
60+
} else {
61+
indicator = app_indicator_new_with_path(arena.allocateUtf8String(APP_INDICATOR_ID),
62+
arena.allocateUtf8String(s),
63+
APP_INDICATOR_CATEGORY_APPLICATION_STATUS(),
64+
// find tray icons theme in mounted AppImage / installed on system by ppa
65+
arena.allocateUtf8String(svgSourcePath.get()));
66+
}
5267
}
5368
}
5469

0 commit comments

Comments
 (0)