Skip to content

Commit

Permalink
feat: dark mode tray icon support for linux and windows (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
agazso authored Aug 15, 2023
1 parent 18fa40f commit 863fedb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Binary file added assets/icon-inv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 17 additions & 2 deletions src/electron.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, Menu, Tray } from 'electron'
import { app, Menu, nativeTheme, Tray } from 'electron'
import opener from 'opener'
import { openDashboardInBrowser } from './browser'
import { runLauncher } from './launcher'
Expand Down Expand Up @@ -47,6 +47,21 @@ export function rebuildElectronTray() {
tray.setContextMenu(contextMenu)
}

function getTrayIcon() {
if (process.platform === 'darwin') {
// on macOS the resolution and dark/light is managed automatically
return getAssetPath('trayTemplate.png')
}

const isDark = nativeTheme.shouldUseDarkColors

if (isDark) {
return getAssetPath('icon-inv.png')
}

return getAssetPath('icon.png')
}

export function runElectronTray() {
const gotTheLock = app.requestSingleInstanceLock()

Expand All @@ -63,7 +78,7 @@ export function runElectronTray() {
app.dock.setIcon(getAssetPath('icon.png'))
app.dock.hide()
}
tray = new Tray(getAssetPath('trayTemplate.png'))
tray = new Tray(getTrayIcon())
rebuildElectronTray()
})
}

0 comments on commit 863fedb

Please sign in to comment.