Skip to content

Commit 5c8add3

Browse files
committed
Load libappindicator3 from /app/lib
Closes flathub/org.cryptomator.Cryptomator#50
1 parent 26f00bf commit 5c8add3

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/main/java/org/purejava/appindicator/RuntimeHelper.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ final class RuntimeHelper {
2929
private static boolean isLoaded = false;
3030
private static final String LD_CONFIG = "/etc/ld.so.conf.d/";
3131
private static final String LIB_NAME_VERSION = "libappindicator3.so.1";
32+
private static final String FLATPAK_LIB_NAME_VERSION = "libappindicator3.so";
3233
private static List<String> allPath = new LinkedList<>();
3334
private static final Logger LOG = LoggerFactory.getLogger(RuntimeHelper.class);
3435

@@ -50,14 +51,20 @@ final class RuntimeHelper {
5051
}
5152

5253
allPath.add("/usr/lib"); // for systems, that don't implement multiarch
54+
allPath.add("/app/lib"); // for flatpak and libraries in the flatpak sandbox
5355
for (String path : allPath) {
5456
try {
55-
System.load(path + File.separator + LIB_NAME_VERSION);
57+
if (!path.equals("/app/lib")) {
58+
System.load(path + File.separator + LIB_NAME_VERSION);
59+
} else {
60+
// flatpak has an own, self-compiled version
61+
System.load(path + File.separator + FLATPAK_LIB_NAME_VERSION);
62+
}
5663
isLoaded = true;
5764
break;
5865
} catch (UnsatisfiedLinkError ignored) { }
5966
}
60-
LOG.info(isLoaded ? "Native code library " + LIB_NAME_VERSION + " successfully loaded" : "Native code library " + LIB_NAME_VERSION + " failed to load");
67+
LOG.info(isLoaded ? "Native code library libappindicator3 successfully loaded" : "Native code library libappindicator3 failed to load");
6168
SymbolLookup loaderLookup = SymbolLookup.loaderLookup();
6269
SYMBOL_LOOKUP = name -> loaderLookup.find(name).or(() -> LINKER.defaultLookup().find(name));
6370
}

src/test/java/org/purejava/appindicator/AppIndicatorTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class AppIndicatorTest {
2121
private static boolean isLoaded = false;
2222
private static final String LD_CONFIG = "/etc/ld.so.conf.d/";
2323
private static final String LIB_NAME_VERSION = "libappindicator3.so.1";
24+
private static final String FLATPAK_LIB_NAME_VERSION = "libappindicator3.so";
2425
private static List<String> allPath = new LinkedList<>();
2526

2627
@Test
@@ -42,13 +43,19 @@ public void shouldHaveNoErrors() {
4243
}
4344

4445
allPath.add("/usr/lib"); // for systems, that don't implement multiarch
46+
allPath.add("/app/lib"); // for flatpak and libraries in the flatpak sandbox
4547
for (String path : allPath) {
4648
try {
47-
System.load(path + File.separator + LIB_NAME_VERSION);
49+
if (!path.equals("/app/lib")) {
50+
System.load(path + File.separator + LIB_NAME_VERSION);
51+
} else {
52+
// flatpak has an own, self-compiled version
53+
System.load(path + File.separator + FLATPAK_LIB_NAME_VERSION);
54+
}
4855
isLoaded = true;
4956
break;
5057
} catch (UnsatisfiedLinkError ignored) { }
5158
}
52-
LOG.info(isLoaded ? "Native code library " + LIB_NAME_VERSION + " successfully loaded" : "Native code library " + LIB_NAME_VERSION + " failed to load");
59+
LOG.info(isLoaded ? "Native code library libappindicator3 successfully loaded" : "Native code library libappindicator3 failed to load");
5360
}
5461
}

0 commit comments

Comments
 (0)