From dfceca48a743aa0297d1ccb6f20b1c3da387d6d5 Mon Sep 17 00:00:00 2001 From: Eva Ho Date: Wed, 19 Jul 2023 11:13:49 -0400 Subject: [PATCH] update icons to have different images for bright and dark mode --- .../ollama_outline_icon_16x16Template.png | Bin 0 -> 445 bytes .../ollama_outline_icon_16x16Template@2x.png | Bin 0 -> 891 bytes app/forge.config.ts | 2 ++ app/src/index.ts | 22 +++++++++++++++--- 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 app/assets/ollama_outline_icon_16x16Template.png create mode 100644 app/assets/ollama_outline_icon_16x16Template@2x.png diff --git a/app/assets/ollama_outline_icon_16x16Template.png b/app/assets/ollama_outline_icon_16x16Template.png new file mode 100644 index 0000000000000000000000000000000000000000..04ef6561732834ac616463ad2b21a7fc083d117f GIT binary patch literal 445 zcmV;u0Yd(XP)kHpvaqnQU{bbt zDGOQnp61+K*St6H)~9C9%sKbmduK%ck52TZ#5*d){|tTM18-;x;_nvk_7m!Z0;~A6 zmm6_!?=0in;yK*7gu0+W5ixo(jaG|m;+`e?k8(wtfA!??sEW>A(2qu&Y~ zU?q5_oh(>~x({P%11BCpEP)K~#7F#aB&8 zRY4T~v?#GKE2BTkr;9|f(C7~edWr5Lg4!C=CTkT$)FRNRRZ1ANil9Y{pxQ)5L4iR( z2vHJ+7*tAx_9K>wSx4tXaU{SB;ehZD*(aQv#ePx9{uKkt8)xZg(s6n;i~V8R{1X1A-i`zazD5H% zNBv$F`xmsiAUsX|Ir2m~>{o9P?xy}-SSTzKrpN+eiDRD@HahLtWtfS0R5I%xTX@46+3<>FCYEwN6|2 zMu+g0aGtPU*aov4iv7Y*j{P^}fg0E~bom6)Yq|_(siMZLLXJowGoL@R-3|MdapRuS z)=gb)FGUV`=)Cv<%*M+Vnkffi_Ky0x>pQRkHu614j(x~X&na<+#yyxmyr$0+;f}%x z<295IoM+pRx%O#c7fcp(Q+MmeW?_@lzEA1;h{YX7dy4HAwzZJx?(c-1(g`wXw+olR zo&(MFah~lf;g?0tzyM`XY&KGAE*}#ff|;Ey!a3wRVLwbQXoWqpYbdKJ-@*eskeRQdS@yk4RsXQ+lQ0cGxMcL~>L*{u+D+6vO1Q4$$IKg#4kt zf@3{04WlZdR=k_ktC0OaU@EMHtr1s!2Wi2XmODKWWQ`U#ub-6Q`mGns1xSuk*gen` z?u=T3I!fK;qeu>|eErnx;SoR?C84+FD(XYw&c9N4;SkW` R<$M4D002ovPDHLkV1j3sofiNA literal 0 HcmV?d00001 diff --git a/app/forge.config.ts b/app/forge.config.ts index c49c44c0..57e6f6dc 100644 --- a/app/forge.config.ts +++ b/app/forge.config.ts @@ -21,6 +21,8 @@ const config: ForgeConfig = { '../ollama', path.join(__dirname, './assets/ollama_icon_16x16Template.png'), path.join(__dirname, './assets/ollama_icon_16x16Template@2x.png'), + path.join(__dirname, './assets/ollama_outline_icon_16x16Template.png'), + path.join(__dirname, './assets/ollama_outline_icon_16x16Template@2x.png'), ...(process.platform === 'darwin' ? ['../llama/ggml-metal.metal'] : []), ], ...(process.env.SIGN diff --git a/app/src/index.ts b/app/src/index.ts index d235c6e8..a88afdc2 100644 --- a/app/src/index.ts +++ b/app/src/index.ts @@ -1,5 +1,5 @@ import { spawn } from 'child_process' -import { app, autoUpdater, dialog, Tray, Menu, BrowserWindow } from 'electron' +import { app, autoUpdater, dialog, Tray, Menu, BrowserWindow, nativeTheme } from 'electron' import Store from 'electron-store' import winston from 'winston' import 'winston-daily-rotate-file' @@ -66,14 +66,30 @@ function firstRunWindow() { } function createSystemtray() { - let iconPath = path.join(__dirname, '..', '..', 'assets', 'ollama_icon_16x16Template.png') + let iconPath = nativeTheme.shouldUseDarkColors + ? path.join(__dirname, '..', '..', 'assets', 'ollama_icon_16x16Template.png') + : path.join(__dirname, '..', '..', 'assets', 'ollama_outline_icon_16x16Template.png') if (app.isPackaged) { - iconPath = path.join(process.resourcesPath, 'ollama_icon_16x16Template.png') + iconPath = nativeTheme.shouldUseDarkColors + ? path.join(process.resourcesPath, 'ollama_icon_16x16Template.png') + : path.join(process.resourcesPath, 'ollama_outline_icon_16x16Template.png') } tray = new Tray(iconPath) + nativeTheme.on('updated', function theThemeHasChanged () { + if (nativeTheme.shouldUseDarkColors) { + app.isPackaged + ? tray.setImage(path.join(process.resourcesPath, 'ollama_icon_16x16Template.png')) + : tray.setImage(path.join(__dirname, '..', '..', 'assets', 'ollama_icon_16x16Template.png')) + } else { + app.isPackaged + ? tray.setImage(path.join(process.resourcesPath, 'ollama_outline_icon_16x16Template.png')) + : tray.setImage(path.join(__dirname, '..', '..', 'assets', 'ollama_outline_icon_16x16Template.png')) + } + }) + const contextMenu = Menu.buildFromTemplate([{ role: 'quit', label: 'Quit Ollama', accelerator: 'Command+Q' }]) tray.setContextMenu(contextMenu)