From 55805f1d8fba4d1e96dba3ef02ec56c5de349778 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Thu, 19 Oct 2017 16:18:10 +0200 Subject: [PATCH] fix(System tray): Add macOS dark theme system tray icon Fixes #1 --- .../images/tray/darwin-dark/tray-active.png | Bin 0 -> 396 bytes .../tray/darwin-dark/tray-active@2x.png | Bin 0 -> 1291 bytes .../tray/darwin-dark/tray-unread-active.png | Bin 0 -> 424 bytes .../darwin-dark/tray-unread-active@2x.png | Bin 0 -> 1359 bytes .../images/tray/darwin-dark/tray-unread.png | Bin 0 -> 424 bytes .../tray/darwin-dark/tray-unread@2x.png | Bin 0 -> 1359 bytes src/assets/images/tray/darwin-dark/tray.png | Bin 0 -> 396 bytes .../images/tray/darwin-dark/tray@2x.png | Bin 0 -> 1291 bytes src/lib/Tray.js | 27 +++++++++++------- 9 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 src/assets/images/tray/darwin-dark/tray-active.png create mode 100644 src/assets/images/tray/darwin-dark/tray-active@2x.png create mode 100644 src/assets/images/tray/darwin-dark/tray-unread-active.png create mode 100644 src/assets/images/tray/darwin-dark/tray-unread-active@2x.png create mode 100644 src/assets/images/tray/darwin-dark/tray-unread.png create mode 100644 src/assets/images/tray/darwin-dark/tray-unread@2x.png create mode 100644 src/assets/images/tray/darwin-dark/tray.png create mode 100644 src/assets/images/tray/darwin-dark/tray@2x.png diff --git a/src/assets/images/tray/darwin-dark/tray-active.png b/src/assets/images/tray/darwin-dark/tray-active.png new file mode 100644 index 0000000000000000000000000000000000000000..489533dbf91406543ac733eb790be00a8ecdb519 GIT binary patch literal 396 zcmV;70dxL|P)3ZN0003~Nkl@JD87#_%iBhBt4~itCg`yP7OX*{H z?oYR0dOSV8bvpN)`|aB~=bnp7uuOC=#yZrxBucc;Uchun|E+vO5pb2QBc=W|V zY0CFe9NNegR+|>C4}Lfz&jYW(C9nka1Ixg5$j?OFk>D$SGST2wU)2V6!NM@7R;V{2 zo=QJnkGic6sj~%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FZJc1{2Q002ovPDHLkV1o1I BRTcmM literal 0 HcmV?d00001 diff --git a/src/assets/images/tray/darwin-dark/tray-unread-active.png b/src/assets/images/tray/darwin-dark/tray-unread-active.png new file mode 100644 index 0000000000000000000000000000000000000000..e2fd1a822a1883170ac996d41ba5119eff8a9257 GIT binary patch literal 424 zcmV;Z0ayNsP)3ZN0004RNklsEil=!yRnn9q!_sWKlAO zV@6}HR%Ss#h+`%Q+R@_xQPctlpMfiJRYO?ktDZ@)vhI38KSg_ zFO$0B&je&YliW|TRn||_?{`~$-0ydjbR@ZyWNifL^CTxz_2P7rmu3G`lG{ngMCTrx|~1{bHyb;@Ct8RYS_aC%;Fa|@g86C8#?9UK|I4pe8ZN?YHg&jjw3jQ z1zf?I(%3i9`~VO4l;A~1eU@af=l**0ywgyzgdLnOFIgF5sn=LjS?~h}&BMR@j!`-cza`OVD# z%;TGHPD&Cbhg2$R$r_*w=m0hWbwD*R4g3y#1q=cGKqgR=B%8ELY759uP9RKb1igY; zfg;GP;4P<~ug;(jjY^u6w64U6*ddsRNPt%+ocfW8C{qrvln4_rw^;2&B?91~h)Qn*4r6TlH1GxRGUgr-1@1mI zM69z|G}zAaHeHMNBG>?19lOI1S0sHRX`77Y>aJHIsaw)9j~$VO?cggmJ7O#FxhHKJ zs0aSGu-XZHg#T>v;%DF}@Dt`7?*wjf@~TOtrk!vGSQ$azVliX;vQJsQ>Km5w-IC@l zb>d>3YetL|X-16L_6VB+^BU0ZN!tQ^NOYSd40pT2XA7h=3}>TSmRX#`I6Jav0S1V+ z9HQa@S9qv^dV?@zBVw6P+92lS$a;Diu5dqavB3JhxCr#yh{z63z)9c< zU>i9S8h~R!Z2}!@MQU=wY2Z)-ZMbm=NZU5c4oS~STI-XyLDG)}+8Av(;My>66-*_x zNlppsg8UJFQZDHQNizwPAW5^58jIkM_}^`Zq)JK6l9pQtsF$=`(l13Iz>NVH5lMKc z`rP_cl170>;2+>!U<9ZHnt(Q-IpH-Lgq@^P2c2*V=mTCVfZqKWvp;7|7Wpg3#U)7( zduGNC!DODZU{V2I?4`iGr2Ue*WbQCQ$Vhs`)A4-XHG1WJ*O02*M4U)?&|X}U^t2Z4 zLobHZ`B&0TpD$S>=n)(doEK!AfoGif5huU;nz~Y(cScl8I-canT^N(pD*sLSaY<7l z^#`=@G>I=#qYUvCULugW7VnZYk;w3+tC9}NJQD;R(e;v!hUl7=^p2$UA-cS>UecSA zI{os!*YIV)bB?qwVpn!!5OZ1kI!2v#U@!1sNV#E*nLmti`A=Zn1uHRD?*?Eq#=G_< z@G)@3Pm#?Z0mh8(a5~e1IZmVAE560}8xA`i%om%0XMiU$Z!1xdcG?^UP65X;1O+09 z2tTaBIA>}dDJMtH6z~V|4e(bSr4dnw@nNn8RsnOsEN~e!&_6McQsen3k4wb$irWc! zsVldnHv=DFZl0%r?;N>Yz|JLwDqth#Ev5x{6mx6d98@W2MvSr0i+mOM4f7|;IJqg9 z!JI%VFiWQgvqX|WH^!fuA-62cftxW)XANfQcz?Osi+MVU|bgAjr@7ejW{$BF+J)!wLlvaXN~E>i};@DHP^;-d%u>EG51tqN^{A zh!eo8F&Y-evP%lVzX&eGIOa7y+DRADPH&fV(z!F(FfVCOO#45stdevl42oV zIJ)B+RJFkU7?0KpCv6V6fU)Jr;wZ}#Da_kP6L6E0HV;e!KVU3d-}^)m{sYv(S2je( RiAVqd002ovPDHLkV1n}Ba6|wA literal 0 HcmV?d00001 diff --git a/src/assets/images/tray/darwin-dark/tray-unread.png b/src/assets/images/tray/darwin-dark/tray-unread.png new file mode 100644 index 0000000000000000000000000000000000000000..e2fd1a822a1883170ac996d41ba5119eff8a9257 GIT binary patch literal 424 zcmV;Z0ayNsP)3ZN0004RNklsEil=!yRnn9q!_sWKlAO zV@6}HR%Ss#h+`%Q+R@_xQPctlpMfiJRYO?ktDZ@)vhI38KSg_ zFO$0B&je&YliW|TRn||_?{`~$-0ydjbR@ZyWNifL^CTxz_2P7rmu3G`lG{ngMCTrx|~1{bHyb;@Ct8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^UP65X;1O+09 z2tTaBIA>}dDJMtH6z~V|4e(bSr4dnw@nNn8RsnOsEN~e!&_6McQsen3k4wb$irWc! zsVldnHv=DFZl0%r?;N>Yz|JLwDqth#Ev5x{6mx6d98@W2MvSr0i+mOM4f7|;IJqg9 z!JI%VFiWQgvqX|WH^!fuA-62cftxW)XANfQcz?Osi+MVU|bgAjr@7ejW{$BF+J)!wLlvaXN~E>i};@DHP^;-d%u>EG51tqN^{A zh!eo8F&Y-evP%lVzX&eGIOa7y+DRADPH&fV(z!F(FfVCOO#45stdevl42oV zIJ)B+RJFkU7?0KpCv6V6fU)Jr;wZ}#Da_kP6L6E0HV;e!KVU3d-}^)m{sYv(S2je( RiAVqd002ovPDHLkV1n}Ba6|wA literal 0 HcmV?d00001 diff --git a/src/assets/images/tray/darwin-dark/tray.png b/src/assets/images/tray/darwin-dark/tray.png new file mode 100644 index 0000000000000000000000000000000000000000..489533dbf91406543ac733eb790be00a8ecdb519 GIT binary patch literal 396 zcmV;70dxL|P)3ZN0003~Nkl@JD87#_%iBhBt4~itCg`yP7OX*{H z?oYR0dOSV8bvpN)`|aB~=bnp7uuOC=#yZrxBucc;Uchun|E+vO5pb2QBc=W|V zY0CFe9NNegR+|>C4}Lfz&jYW(C9nka1Ixg5$j?OFk>D$SGST2wU)2V6!NM@7R;V{2 zo=QJnkGic6sj~%&s(z`H>X^E#P9(x5>J)GRv;xz>L=iLI1lECjpa&O7gg+MguYK(R0000e~;7!wJ`jT;w4T^Ju2 zjmDL-5PX27(Lg{XxY3G_Xaj1YD7}J2%kBNUI5W4GVb08%+xtTOCnufL`Mz`h^Plth z&NmnS2LPTV+r1$m2aHsVP3h4DJOFG1#-j{8&odX2Y-LPRR?=lLHnmQ?}ZiX>GHtPItgk{n!xh-%!1OMo|k3@{0N20V`0*Ilp_ z*aYkcP5~3Z^T36U{!v`(6Fn@U=b+BTs}3RUDoK+OzLIoC(z}vYOR5X`&5<-LX@{ho z#s7$;ixibL@%!8L<{f{XU7T`1IsP;9?%fipvze!zz3Ms zIOErQf$f;!r5fl2K4xZHAIF@O_gU;?dD?^soP^0x-3F{?Mucu)2hi?7xSY5gGcsEJ z`Vn9S@DT7t$TsTb=3z_K-2`+2JAq$9_j-X3fhB1eml+2!FDjglTLRpI;ruLcJnZO_ zstcC}Nsmc7S%$^06gVpBUP+!(r1SEENSX`u06$_PxiGqbwZNnPb*qjH-B{1N5-d|vZ zu;%ms1Gv%iyb*BEN0b^l;5lFo@LH8P0Q{W4lC-PBi`w6k?g=eg8!F5}lC~%mVz)}# zS)tAkOS)dsEBLLFPE?4;TQVo!vxGqASiD}+@iKLslk~ErHpOpeU6QtziGyTLy>}~O z`wSDAC+QJMdrR2)c1hPNUVv~JlC---{ZC8!MAH3|8pC}Bi2DfKjfpTtl<1Cx|p1S|xyz-eF#^PtBtyTC-6MvE2Ve8pm5Eb2xegzb#p2fT?ndF}ze@yk@H z8I}Rfz%tCYn10NmD}y~(0mP4p!U9`lx}(kWn455aHdqF%E5dJEl0jUE z{dy4{)*?o+XRY#x6JnoB1LpxYyBH-Mx}Gcnk!s>QV2g`kk`TLqCsK4Q;ExpcX^}}b z$zuYz3)h`4MaVlM`{%eIlzqyvy<*EkN&6E*>XVXQkksMQW`MK-RXcDECZn~$|6dk3 z3hc#fx#fn3`F&ImGarVhF=@H)F_G;V=f?c)^B)bEY|FZJc1{2Q002ovPDHLkV1o1I BRTcmM literal 0 HcmV?d00001 diff --git a/src/lib/Tray.js b/src/lib/Tray.js index 631342b24..ca6131c0c 100644 --- a/src/lib/Tray.js +++ b/src/lib/Tray.js @@ -1,16 +1,10 @@ -import { app, Tray, Menu } from 'electron'; +import { app, Tray, Menu, systemPreferences } from 'electron'; import path from 'path'; const FILE_EXTENSION = process.platform === 'win32' ? 'ico' : 'png'; const INDICATOR_TRAY_PLAIN = 'tray'; const INDICATOR_TRAY_UNREAD = 'tray-unread'; -function getAsset(type, asset) { - return path.join( - __dirname, '..', 'assets', 'images', type, process.platform, `${asset}.${FILE_EXTENSION}`, - ); -} - export default class TrayIcon { mainWindow = null; trayIcon = null; @@ -20,7 +14,7 @@ export default class TrayIcon { } show() { - this.trayIcon = new Tray(getAsset('tray', INDICATOR_TRAY_PLAIN)); + this.trayIcon = new Tray(this._getAsset('tray', INDICATOR_TRAY_PLAIN)); const trayMenuTemplate = [ { label: 'Show Franz', @@ -53,12 +47,25 @@ export default class TrayIcon { setIndicator(indicator) { if (!this.trayIcon) return; - this.trayIcon.setImage(getAsset('tray', indicator !== 0 ? INDICATOR_TRAY_UNREAD : INDICATOR_TRAY_PLAIN)); + this.trayIcon.setImage(this._getAsset('tray', indicator !== 0 ? INDICATOR_TRAY_UNREAD : INDICATOR_TRAY_PLAIN)); if (process.platform === 'darwin') { this.trayIcon.setPressedImage( - getAsset('tray', `${indicator !== 0 ? INDICATOR_TRAY_UNREAD : INDICATOR_TRAY_PLAIN}-active`), + this._getAsset('tray', `${indicator !== 0 ? INDICATOR_TRAY_UNREAD : INDICATOR_TRAY_PLAIN}-active`), ); } } + + + _getAsset(type, asset) { + let platform = process.platform; + + if (platform === 'darwin' && systemPreferences.isDarkMode()) { + platform = `${platform}-dark`; + } + + return path.join( + __dirname, '..', 'assets', 'images', type, platform, `${asset}.${FILE_EXTENSION}`, + ); + } }