Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Sep 15, 2023
2 parents 85db5c7 + 7a15e92 commit d3be8af
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# integrations-linux
Linux-specific implemenations of the integrations-api
Linux-specific implemenations of the [integrations-api](https://github.com/cryptomator/integrations-api).

# Config

This project uses the following JVM properties:
* `cryptomator.integrationsLinux.trayIconsDir` - specifies the directory from which svg images for the tray icon are loaded

9 changes: 4 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.cryptomator</groupId>
<artifactId>integrations-linux</artifactId>
<version>1.3.0-SNAPSHOT</version>
<version>1.4.0-SNAPSHOT</version>

<name>integrations-linux</name>
<description>Provides optional Linux services used by Cryptomator</description>
Expand Down Expand Up @@ -40,10 +40,10 @@

<!-- runtime dependencies -->

<api.version>1.3.0-beta1</api.version>
<api.version>1.3.0</api.version>
<secret-service.version>1.8.1-jdk17</secret-service.version>
<kdewallet.version>1.3.2</kdewallet.version>
<appindicator.version>1.3.0</appindicator.version>
<appindicator.version>1.3.4</appindicator.version>
<guava.version>32.0.0-jre</guava.version>
<slf4j.version>1.7.36</slf4j.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
Expand Down Expand Up @@ -91,8 +91,7 @@
<!-- Java bindings for appindicator -->
<dependency>
<groupId>org.purejava</groupId>
<artifactId>appindicator-gtk3-java</artifactId>
<classifier>libayatana-appindicator-libappindicator-minimal</classifier>
<artifactId>libappindicator-gtk3-java-minimal</artifactId>
<version>${appindicator.version}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cryptomator.linux.tray;

import org.apache.commons.lang3.StringUtils;
import org.cryptomator.integrations.common.CheckAvailability;
import org.cryptomator.integrations.common.OperatingSystem;
import org.cryptomator.integrations.common.Priority;
Expand All @@ -11,29 +12,32 @@
import org.cryptomator.integrations.tray.TrayMenuException;
import org.cryptomator.integrations.tray.TrayMenuItem;
import org.purejava.appindicator.GCallback;
import org.purejava.appindicator.MemoryAllocator;
import org.purejava.appindicator.NativeLibUtilities;

import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.SegmentScope;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;

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

@Priority(1000)
@CheckAvailability
@OperatingSystem(OperatingSystem.Value.LINUX)
public class AppindicatorTrayMenuController implements TrayMenuController {

private static final String APP_INDICATOR_ID = "org.cryptomator.Cryptomator";
private static final String SVG_SOURCE_PROPERTY = "cryptomator.integrationsLinux.trayIconsDir";

private static final SegmentScope SCOPE = SegmentScope.global();
private MemorySegment indicator;
private MemorySegment menu = gtk_menu_new();
private Optional<String> svgSourcePath;

@CheckAvailability
public static boolean isAvailable() {
return MemoryAllocator.isLoadedNativeLib();
return NativeLibUtilities.isLoadedNativeLib();
}

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

private void showTrayIconWithSVG(String s) {
try (var arena = Arena.openConfined()) {
indicator = app_indicator_new(arena.allocateUtf8String(APP_INDICATOR_ID),
arena.allocateUtf8String(s),
APP_INDICATOR_CATEGORY_APPLICATION_STATUS());
svgSourcePath = Optional.ofNullable(System.getProperty(SVG_SOURCE_PROPERTY));
// flatpak
if (svgSourcePath.isEmpty()) {
indicator = app_indicator_new(arena.allocateUtf8String(APP_INDICATOR_ID),
arena.allocateUtf8String(s),
APP_INDICATOR_CATEGORY_APPLICATION_STATUS());
// AppImage and ppa
} else {
indicator = app_indicator_new_with_path(arena.allocateUtf8String(APP_INDICATOR_ID),
arena.allocateUtf8String(s),
APP_INDICATOR_CATEGORY_APPLICATION_STATUS(),
// find tray icons theme in mounted AppImage / installed on system by ppa
arena.allocateUtf8String(svgSourcePath.get()));
}
}
}

Expand Down

0 comments on commit d3be8af

Please sign in to comment.