From 26a710d0c2b43915e0d9d167666d364f303c4389 Mon Sep 17 00:00:00 2001 From: Ben Kaufman Date: Sun, 3 Mar 2019 22:37:05 +0200 Subject: [PATCH] Fix system tray visibility for dark mode Mac --- .../main/java/bisq/common/util/Utilities.java | 15 +++++++++++++++ .../main/java/bisq/desktop/app/SystemTray.java | 8 +++++++- .../images/system_tray_icon@2x_white.png | Bin 0 -> 1988 bytes .../resources/images/system_tray_icon_white.png | Bin 0 -> 1125 bytes 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 desktop/src/main/resources/images/system_tray_icon@2x_white.png create mode 100644 desktop/src/main/resources/images/system_tray_icon_white.png diff --git a/common/src/main/java/bisq/common/util/Utilities.java b/common/src/main/java/bisq/common/util/Utilities.java index acab7b15a5..000a48c899 100644 --- a/common/src/main/java/bisq/common/util/Utilities.java +++ b/common/src/main/java/bisq/common/util/Utilities.java @@ -155,6 +155,21 @@ public class Utilities { return executor; } + /** + * @return true if defaults read -g AppleInterfaceStyle has an exit status of 0 (i.e. _not_ returning "key not found"). + */ + public static boolean isMacMenuBarDarkMode() { + try { + // check for exit status only. Once there are more modes than "dark" and "default", we might need to analyze string contents.. + final Process process = Runtime.getRuntime().exec(new String[] {"defaults", "read", "-g", "AppleInterfaceStyle"}); + process.waitFor(100, TimeUnit.MILLISECONDS); + return process.exitValue() == 0; + } catch (IOException | InterruptedException | IllegalThreadStateException ex) { + // IllegalThreadStateException thrown by proc.exitValue(), if process didn't terminate + return false; + } + } + public static boolean isUnix() { return isOSX() || isLinux() || getOSName().contains("freebsd"); } diff --git a/desktop/src/main/java/bisq/desktop/app/SystemTray.java b/desktop/src/main/java/bisq/desktop/app/SystemTray.java index 1f75aed724..61f4c83221 100644 --- a/desktop/src/main/java/bisq/desktop/app/SystemTray.java +++ b/desktop/src/main/java/bisq/desktop/app/SystemTray.java @@ -52,6 +52,8 @@ public class SystemTray { private static final String ICON_HI_RES = "/images/system_tray_icon@2x.png"; private static final String ICON_LO_RES = "/images/system_tray_icon.png"; + private static final String ICON_HI_RES_WHITE = "/images/system_tray_icon@2x_white.png"; + private static final String ICON_LO_RES_WHITE = "/images/system_tray_icon_white.png"; private static final String ICON_WINDOWS_LO_RES = "/images/system_tray_icon_windows.png"; private static final String ICON_WINDOWS_HI_RES = "/images/system_tray_icon_windows@2x.png"; private static final String ICON_LINUX = "/images/system_tray_icon_linux.png"; @@ -97,7 +99,11 @@ public class SystemTray { String path; if (Utilities.isOSX()) - path = ImageUtil.isRetina() ? ICON_HI_RES : ICON_LO_RES; + if (Utilities.isMacMenuBarDarkMode()) + path = ImageUtil.isRetina() ? ICON_HI_RES_WHITE : ICON_LO_RES_WHITE; + else + path = ImageUtil.isRetina() ? ICON_HI_RES : ICON_LO_RES; + else if (Utilities.isWindows()) path = ImageUtil.isRetina() ? ICON_WINDOWS_HI_RES : ICON_WINDOWS_LO_RES; else diff --git a/desktop/src/main/resources/images/system_tray_icon@2x_white.png b/desktop/src/main/resources/images/system_tray_icon@2x_white.png new file mode 100644 index 0000000000000000000000000000000000000000..555e8cb81b3cab8f0aa0c57597c0d8973bc4ba13 GIT binary patch literal 1988 zcmY*aeLNFdAKw~_+3bqO^vD`bGTXeQ*=2@Nxzw^gAS#B-|U=VEx004kF z9i$$WTgv8C0?XG5)~QLkQDE2}wgmuc^Hlz#DFOgMAC|i}*ZZ(DDL9;iqn!v3qT_g+ z2ssb{u;P*AE{D#gp?Dm2SQLq8jsAil$^FeR9*z0};f7kHy$`#g?877JsC_td905&+ zpin5Q$P*!?qg2Ol>GGX5n#tuxkns4Jm>67)87@4Mfj6y za0L8!Zh5NJW|ZU_$)d}ZH~GmXR$q|+7yG7Th2IqapJKjt`XwrFl?<`Mf4?>|#JR)3 z2LJ#goT#?$JfO5FG!x;W)g3d64fn6FyzE}quTX!pDsyx;i1y$#{)o(tOOtI=SpRK{ z%q^daR7_OP!Eu3pdz;jJQ6XG4>=U+1Z?E~jBcb&lq^sq{V!^+K0>+!-*s;3_N!ba4cVKFIcWUU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jg}B**Xp>le77v^ms~k$sOvM>_vci%kxP|#K$*Wm*&o; zDfK;v>g*G2gtK`hm^%%I}h6H6qY*!5YM~GrQ(2vbC$0z&f<0-6n+a literal 0 HcmV?d00001 diff --git a/desktop/src/main/resources/images/system_tray_icon_white.png b/desktop/src/main/resources/images/system_tray_icon_white.png new file mode 100644 index 0000000000000000000000000000000000000000..c71aa6189cb657f03d1e6189781d520690eaf315 GIT binary patch literal 1125 zcmeAS@N?(olHy`uVBq!ia0vp^ia@Nu!3HGf><~N!q*&4&eH|GXHuiJ>Nn~YUV2sQR zi71Ki^|4CM&(%vz$xlkvtH>8?tx|+mh4pF`@A3=B-$JzX3_A~@ep^Y@tIC~~0Obm5=t zii>(Sv>eEG32@|QtI|*s`(C#+k(qI*FFuMewl(M)X?k>{HORtVXx z=!?Jb{_vbnk+1USSU<@%2y#*^;X%LL~YMehDFN6;qWhtbZonKum7Zu884n{;&X!O1n7l#Q!T z+VjdcTO}>C3xDQg?))HUg3S!$lN<}&G)o$6t_Zp8Kf>{kGpeeVf6k}d6U)5*%#rI{ zd8JJ6?k(Ym->2m3i2G|FHd?djd#Aq0pG_wO{}g4{wI(O_q(*l~@G$+IeEy++Y4P-o z0MR3zl_GwY|K*RdE>D+T)B9;!kJVJw*5r>BH9g1F1J)lh`PTJ=dFFwAuWQOXX7WE< zJkw+sThx+JHc$O0 z`8VGAi*kX3_>sKke1TKBvf`f04_)5SwK?_too44<0^d9*{7vrsvG(!`@0@F%TFveg ze4ospCKLbqWbM2fvHJTtc_K%h8}%Z-iGG%-7p!LHvWv`oz4(ITi$;y^iS