Skip to content

Commit 8de5733

Browse files
authored
Merge pull request #22 from purejava/release/1.3.0
Show icons also for flatpacked app
2 parents 7ab7629 + d019418 commit 8de5733

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<api.version>1.3.0-beta1</api.version>
4444
<secret-service.version>1.8.1-jdk17</secret-service.version>
4545
<kdewallet.version>1.3.0</kdewallet.version>
46-
<appindicator.version>1.3.1</appindicator.version>
46+
<appindicator.version>1.3.2</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>

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

Lines changed: 16 additions & 11 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.trayIconsDir";
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,18 +50,20 @@ public void showTrayIcon(Consumer<TrayIconLoader> iconLoader, Runnable runnable,
4750

4851
private void showTrayIconWithSVG(String s) {
4952
try (var arena = Arena.openConfined()) {
50-
var appdir = System.getenv("APPDIR");
51-
if (null == appdir || appdir.isBlank()) {
52-
appdir = "";
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()));
5366
}
54-
if (appdir.endsWith("/")) {
55-
appdir = StringUtils.chop(appdir);
56-
}
57-
indicator = app_indicator_new_with_path(arena.allocateUtf8String(APP_INDICATOR_ID),
58-
arena.allocateUtf8String(s),
59-
APP_INDICATOR_CATEGORY_APPLICATION_STATUS(),
60-
// find tray icons theme in mounted AppImage
61-
arena.allocateUtf8String(appdir + "/usr/share/icons/hicolor/symbolic/apps"));
6267
}
6368
}
6469

0 commit comments

Comments
 (0)