Skip to content

Commit

Permalink
Merge pull request #3 from alexargo/master
Browse files Browse the repository at this point in the history
Adding handling for light mode / dark mode
  • Loading branch information
1kc authored Apr 20, 2020
2 parents 051c840 + 6ae90d6 commit 4687bc7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"source-map-support": "^0.5.12"
},
"devDependencies": {
"electron": "5.0.6",
"electron": "8.2.3",
"electron-builder": "^21.0.11",
"electron-webpack": "^2.7.4",
"webpack": "~4.35.3"
Expand Down
File renamed without changes
Binary file added src/assets/icon-lightmode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 24 additions & 7 deletions src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import { app, Menu, Tray } from 'electron'
import { app, Menu, Tray, nativeTheme } from 'electron'
import addon from '../driver'
import * as path from 'path'

Expand All @@ -9,11 +9,31 @@ import * as path from 'path'

let tray = null


app.on('ready', () => {
createTray();
})

app.on('quit', () => {
addon.closeDevice();
})

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

function createTray() {
if (app.dock) app.dock.hide()

tray = new Tray(path.join(__dirname, '../assets/icon.png'))
if(tray != null) {
tray.destroy();
}

if(nativeTheme.shouldUseDarkColors) {
tray = new Tray(path.join(__dirname, '../assets/icon-darkmode.png'))
} else {
tray = new Tray(path.join(__dirname, '../assets/icon-lightmode.png'))
}

const contextMenu = Menu.buildFromTemplate([
{
label: addon.getDevice(),
Expand Down Expand Up @@ -74,8 +94,5 @@ app.on('ready', () => {
])
tray.setToolTip('This is my application.')
tray.setContextMenu(contextMenu)
})

app.on('quit', () => {
addon.closeDevice();
})
}

0 comments on commit 4687bc7

Please sign in to comment.