Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/windows' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
addyire committed Nov 29, 2021
2 parents 427cd70 + 883e5e8 commit aa17844
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@ const itemBuilder = require('./modules/itemBuilder')
const { importConfig, exportConfig } = require('./modules/configuration')

// set some variables
const isWindows = process.platform === 'win32'
let refreshInterval = settings.get('refreshInterval') * 60 * 1000 // default to 30 minutes
let win, tray

if (isWindows && app.isPackaged && process.argv.length >= 2) {
(async () => {
await app.whenReady()
dialog.showErrorBox({
title: 'Feature Not Supported',
message: 'Please import the configuration file from the preferences window.'
})
process.exit()
})()
}

// open the preferences window
const openPreferences = () => {
log.info('Opening preferences window')
Expand All @@ -19,7 +31,7 @@ const openPreferences = () => {
// create the preference window
win = new BrowserWindow({
width: 850,
height: 670,
height: isWindows ? 700 : 670,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
Expand Down Expand Up @@ -70,6 +82,9 @@ const buildTray = async () => {
// create the tray if one doesnt exist
if (!tray) tray = new Tray(PATHS.MENUBAR_ICONS.TRANSPARENT)

// open tray on click on windows
isWindows && tray.on('click', () => tray.popUpContextMenu())

// set the tray icon to be transparent to indicate reload
tray.setImage(PATHS.MENUBAR_ICONS.TRANSPARENT)

Expand All @@ -95,9 +110,9 @@ const buildTray = async () => {
})
} else {
// otherwise, set the tray title
if (config.titleTemplate) {
if (!isWindows && config.titleTemplate) {
trayTitle = await hass.render(config.titleTemplate)
} else if (config.title) {
} else if (!isWindows && config.title) {
trayTitle = config.title
}

Expand Down Expand Up @@ -146,7 +161,7 @@ app.on('open-file', async (event, path) => {
app.on('ready', async () => {
log.info('App is ready')
// hide from dock
app.dock.hide()
!isWindows && app.dock.hide()
const autoRebuild = () => {
// build the tray
buildTray()
Expand Down

0 comments on commit aa17844

Please sign in to comment.