Skip to content

Commit

Permalink
feat: monochrome tray icon on Windows & Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed May 26, 2022
1 parent ac17bb2 commit 49da5ce
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 5 deletions.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file removed assets/icons/tray/off-big.png
Binary file not shown.
Binary file removed assets/icons/tray/on-big.png
Binary file not shown.
Binary file added assets/icons/tray/others/off-32-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/tray/others/off-32-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/tray/others/on-32-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/tray/others/on-32-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/macOS-icon.sketch
Binary file not shown.
Binary file added assets/tray.sketch
Binary file not shown.
15 changes: 10 additions & 5 deletions src/tray.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Menu, Tray, shell, app, ipcMain } = require('electron')
const { Menu, Tray, shell, app, ipcMain, nativeTheme } = require('electron')
const i18n = require('i18next')
const path = require('path')
const addToIpfs = require('./add-to-ipfs')
Expand Down Expand Up @@ -219,14 +219,15 @@ function buildMenu (ctx) {
const on = 'on'
const off = 'off'

function icon (color) {
function icon (status) {
const dir = path.resolve(path.join(__dirname, '../assets/icons/tray'))

if (!IS_MAC) {
return path.join(dir, `${color}-big.png`)
if (IS_MAC) {
return path.join(dir, 'macos', `${status}-22Template.png`)
}

return path.join(dir, `${color}-22Template.png`)
const theme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light'
return path.join(dir, 'others', `${status}-32-${theme}.png`)
}

// Ok this one is pretty ridiculous:
Expand Down Expand Up @@ -363,6 +364,10 @@ module.exports = function (ctx) {
ipcMain.on('configUpdated', () => { updateMenu() })
ipcMain.on('languageUpdated', () => { setupMenu() })

nativeTheme.on('updated', () => {
updateMenu()
})

setupMenu()

ctx.tray = tray
Expand Down

0 comments on commit 49da5ce

Please sign in to comment.