1818import java .lang .foreign .MemorySegment ;
1919import java .lang .foreign .SegmentScope ;
2020import java .util .List ;
21+ import java .util .Optional ;
2122import java .util .function .Consumer ;
2223
2324import static org .purejava .appindicator .app_indicator_h .*;
2728@ OperatingSystem (OperatingSystem .Value .LINUX )
2829public 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