Skip to content

Commit 6cad88d

Browse files
Merge pull request #7 from PascalLuginbuehl/features
Load accent color, dev tab, better search in autocomplete, quality of life improvements
2 parents f1f77bd + 615679f commit 6cad88d

25 files changed

+225
-35
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ For easy configuration, entities can be added, sorted, and edited using a GUI.
1313

1414
# Installation
1515
- Download from the [Releases page](https://github.com/PascalLuginbuehl/home-assistant-tray-menu/releases) and run the installer EXE.
16-
- Once installation has finished, you should see the Home Assistant icon in your system tray.
16+
- A "Windows protected your PC" message will pop up, click "More info" and then "Run anyway" This is a precaution from Windows because this application is not signed.
17+
- Once the installation is complete, you should see the Home Assistant icon in your system tray.
18+
- Right-click on the tray icon to open settings
1719

1820
# Stack
1921
- Built using electron-forge and react
79.1 KB
Binary file not shown.
17.6 KB
Binary file not shown.
39.1 KB
Loading
172 KB
Binary file not shown.

forge.config.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,24 @@ import { MakerZIP } from '@electron-forge/maker-zip';
44
import { MakerDeb } from '@electron-forge/maker-deb';
55
import { MakerRpm } from '@electron-forge/maker-rpm';
66
import { WebpackPlugin } from '@electron-forge/plugin-webpack';
7-
7+
import path from "path"
88
import { mainConfig } from './webpack.main.config';
99
import { rendererConfig } from './webpack.renderer.config';
1010

1111
const config: ForgeConfig = {
12-
packagerConfig: {},
12+
packagerConfig: {
13+
icon: path.resolve(__dirname, "./assets/home-assistant-icon-pretty"),
14+
},
1315
rebuildConfig: {},
14-
makers: [new MakerSquirrel({}), new MakerZIP({}, ['darwin']), new MakerRpm({}), new MakerDeb({})],
16+
makers: [
17+
new MakerSquirrel({
18+
iconUrl: "https://raw.githubusercontent.com/pascalluginbuehl/home-assistant-tray-menu/main/assets/home-assistant-icon-pretty.ico",
19+
setupIcon: path.resolve(__dirname, "./assets/home-assistant-icon-pretty.ico"),
20+
}),
21+
new MakerZIP({}, ['darwin']),
22+
new MakerRpm({}),
23+
new MakerDeb({})
24+
],
1525
plugins: [
1626
new WebpackPlugin({
1727
mainConfig,

src/i18n/translation_en.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
},
77
"CONNECTION": {
88
"TITLE": "API Connection",
9-
"LONG_LIVED_ACCESS_TOKEN": "Long Lived Access Token",
9+
"LONG_LIVED_ACCESS_TOKEN": "Long-Lived Access Token",
1010
"LAUNCH_AT_STARTUP": "Launch at startup",
1111
"LLAT_UNAUTHORIZED": "long lived access token was not authorized on the server",
1212
"NETWORK_ERROR": "Could not reach server"
1313
},
1414
"ENTITIES": {
1515
"TITLE": "Entities",
1616
"ADD_ENTITY": "Add entity"
17+
},
18+
"DEVELOPMENT": {
19+
"TITLE": "Development",
20+
"KEEP_TRAY_OPEN": "Keep tray open"
1721
}
1822
}

src/index.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
import createTray from './windows/tray';
55
import './ipc-main-handlers';
66
import { checkAPIStatusPeriodically } from './hass-api';
7+
import { showPanel } from './windows/panel-controller';
78

89
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
910
// eslint-disable-next-line global-require
@@ -13,7 +14,24 @@ if (require('electron-squirrel-startup')) {
1314

1415
checkAPIStatusPeriodically();
1516

16-
app.on('ready', () => createTray());
17+
let panelWindow: BrowserWindow | null = null;
18+
19+
const gotTheLock = app.requestSingleInstanceLock();
20+
21+
if (!gotTheLock) {
22+
app.quit();
23+
} else {
24+
app.on('second-instance', () => {
25+
if (panelWindow) {
26+
showPanel();
27+
panelWindow.focus();
28+
}
29+
});
30+
31+
app.on('ready', () => {
32+
panelWindow = createTray();
33+
});
34+
}
1735

1836
// Quit when all windows are closed, except on macOS. There, it's common
1937
// for applications and their menu bar to stay active until the user quits

src/ipc-main-handlers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ipcMain } from 'electron';
1+
import { ipcMain, systemPreferences } from 'electron';
22
import APIUrlStateEnum from './types/api-state-enum';
33
import { setIconStatus } from './windows/tray';
44
import { baseApiClient, checkAPIUrl, setAxiosParameters } from './hass-api';
@@ -52,3 +52,5 @@ ipcMain.handle('electron-store:set', async (event, key, val) => {
5252
setAutoLaunch(val.isAutoLaunchEnabled);
5353
}
5454
});
55+
56+
ipcMain.handle('system:accent', async () => systemPreferences.getAccentColor());

src/preload.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const contextBridgeApi = {
2828
serviceData: { entity_id: string } & Record<string, unknown>,
2929
): Promise<void> => ipcRenderer.invoke('service:call-action', domain, service, serviceData),
3030
},
31+
getAccentColor: async (): Promise<string> => ipcRenderer.invoke('system:accent'),
3132
};
3233

3334
export type ContextBridgeApi = typeof contextBridgeApi;

0 commit comments

Comments
 (0)