Skip to content

Commit be4da36

Browse files
committed
Introduce JVM property for the SVG image loading path
1 parent 4649501 commit be4da36

2 files changed

Lines changed: 25 additions & 18 deletions

File tree

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.appIndicator.svgSource` - specifies the path from which the svg images are loaded
8+

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.lang.foreign.MemorySegment;
1919
import java.lang.foreign.SegmentScope;
2020
import java.util.List;
21+
import java.util.Optional;
2122
import java.util.function.Consumer;
2223

2324
import static org.purejava.appindicator.app_indicator_h.*;
@@ -27,10 +28,12 @@
2728
@OperatingSystem(OperatingSystem.Value.LINUX)
2829
public class AppindicatorTrayMenuController implements TrayMenuController {
2930
private static final String APP_INDICATOR_ID = "org.cryptomator.Cryptomator";
31+
private static final String SVG_SOURCE_PROPERTY = "cryptomator.integrationsLinux.appIndicator.svgSource";
3032

3133
private static final SegmentScope SCOPE = SegmentScope.global();
3234
private MemorySegment indicator;
3335
private MemorySegment menu = gtk_menu_new();
36+
private Optional<String> svgSourcePath;
3437

3538
@CheckAvailability
3639
public static boolean isAvailable() {
@@ -47,29 +50,27 @@ public void showTrayIcon(Consumer<TrayIconLoader> iconLoader, Runnable runnable,
4750

4851
private void showTrayIconWithSVG(String s) {
4952
try (var arena = Arena.openConfined()) {
53+
svgSourcePath = Optional.ofNullable(System.getProperty(SVG_SOURCE_PROPERTY));
5054
// flatpak
51-
if (null != System.getProperty("cryptomator.buildNumber") && System.getProperty("cryptomator.buildNumber").startsWith("flatpak")) {
55+
if (svgSourcePath.isEmpty()) {
5256
indicator = app_indicator_new(arena.allocateUtf8String(APP_INDICATOR_ID),
5357
arena.allocateUtf8String(s),
5458
APP_INDICATOR_CATEGORY_APPLICATION_STATUS());
55-
return;
56-
}
57-
58-
5959
// AppImage and ppa
60-
var appdir = System.getenv("APPDIR");
61-
if (null == appdir || appdir.isBlank()) {
62-
appdir = "";
63-
}
64-
if (appdir.endsWith("/")) {
65-
appdir = StringUtils.chop(appdir);
60+
} else {
61+
var appdir = System.getenv("APPDIR");
62+
if (null == appdir || appdir.isBlank()) {
63+
appdir = "";
64+
}
65+
if (appdir.endsWith("/")) {
66+
appdir = StringUtils.chop(appdir);
67+
}
68+
indicator = app_indicator_new_with_path(arena.allocateUtf8String(APP_INDICATOR_ID),
69+
arena.allocateUtf8String(s),
70+
APP_INDICATOR_CATEGORY_APPLICATION_STATUS(),
71+
// find tray icons theme in mounted AppImage / installed on system by ppa
72+
arena.allocateUtf8String(appdir + svgSourcePath.get()));
6673
}
67-
indicator = app_indicator_new_with_path(arena.allocateUtf8String(APP_INDICATOR_ID),
68-
arena.allocateUtf8String(s),
69-
APP_INDICATOR_CATEGORY_APPLICATION_STATUS(),
70-
// find tray icons theme in mounted AppImage / installed on system by ppa
71-
// depending on preceding 'appdir'
72-
arena.allocateUtf8String(appdir + "/usr/share/icons/hicolor/symbolic/apps"));
7374
}
7475
}
7576

0 commit comments

Comments
 (0)