fix: correctly load badge count; expose to renderer (#25)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import dbus from "@homebridge/dbus-native";
|
import dbus from "@homebridge/dbus-native";
|
||||||
|
|
||||||
import { NativeImage, app, nativeImage } from "electron";
|
import { NativeImage, app, ipcMain, nativeImage } from "electron";
|
||||||
|
|
||||||
import { mainWindow } from "./window";
|
import { mainWindow } from "./window";
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ export async function setBadgeCount(count: number) {
|
|||||||
nativeIcons[count] = nativeImage.createFromDataURL(
|
nativeIcons[count] = nativeImage.createFromDataURL(
|
||||||
await import(
|
await import(
|
||||||
`../../assets/desktop/badges/${Math.min(count, 10)}.ico?asset`
|
`../../assets/desktop/badges/${Math.min(count, 10)}.ico?asset`
|
||||||
),
|
).then((asset) => asset.default),
|
||||||
);
|
);
|
||||||
|
|
||||||
mainWindow.setOverlayIcon(
|
mainWindow.setOverlayIcon(
|
||||||
@@ -65,3 +65,5 @@ export async function setBadgeCount(count: number) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ipcMain.on("setBadgeCount", (_event, count: number) => setBadgeCount(count));
|
||||||
|
|||||||
@@ -13,4 +13,6 @@ contextBridge.exposeInMainWorld("native", {
|
|||||||
minimise: () => ipcRenderer.send("minimise"),
|
minimise: () => ipcRenderer.send("minimise"),
|
||||||
maximise: () => ipcRenderer.send("maximise"),
|
maximise: () => ipcRenderer.send("maximise"),
|
||||||
close: () => ipcRenderer.send("close"),
|
close: () => ipcRenderer.send("close"),
|
||||||
|
|
||||||
|
setBadgeCount: (count: number) => ipcRenderer.send("setBadgeCount", count),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,23 +1,19 @@
|
|||||||
I d#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Check if we're on NixOS and set up electron path if needed
|
# Check if we're on NixOS and set up electron path if needed
|
||||||
if [ -f /etc/NIXOS ] || [ -n "$NIX_STORE" ]; then
|
if [ -f /etc/NIXOS ] || [ -n "$NIX_STORE" ]; then
|
||||||
# We're on NixOS, need to find the electron path
|
# We're on NixOS, need to find the electron path
|
||||||
if command -v electron &> /dev/null; then
|
# Try to find electron in nix store matching our version requirement
|
||||||
# Electron is in PATH, find its store path
|
REQUIRED_VERSION=$(grep '"electron"' package.json | sed -E 's/.*"electron"[[:space:]]*:[[:space:]]*"([0-9]+)\..*/\1/')
|
||||||
ELECTRON_BIN=$(which electron)
|
|
||||||
ELECTRON_STORE_PATH=$(dirname "$ELECTRON_BIN")
|
# Search for electron in nix store
|
||||||
export ELECTRON_OVERRIDE_DIST_PATH="$ELECTRON_STORE_PATH"
|
ELECTRON_PATH=$(ls -d /nix/store/*electron-${REQUIRED_VERSION}* 2>/dev/null | grep -v -E '(unwrapped|\.drv$)' | head -1)
|
||||||
echo "NixOS detected: Using electron from $ELECTRON_STORE_PATH"
|
|
||||||
elif [ -d /nix/store ]; then
|
if [ -n "$ELECTRON_PATH" ] && [ -d "$ELECTRON_PATH/bin" ]; then
|
||||||
# Try to find electron in nix store matching our version requirement
|
export ELECTRON_OVERRIDE_DIST_PATH="$ELECTRON_PATH/bin"
|
||||||
REQUIRED_VERSION=$(grep '"electron"' package.json | sed -E 's/.*"([0-9]+)\..*/\1/')
|
echo "NixOS detected: Using electron from $ELECTRON_PATH/bin"
|
||||||
ELECTRON_PATH=$(find /nix/store -maxdepth 1 -name "*electron-${REQUIRED_VERSION}*" -type d 2>/dev/null | grep -v unwrapped | head -1)
|
else
|
||||||
|
echo "Warning: Could not find electron ${REQUIRED_VERSION} in nix store"
|
||||||
if [ -n "$ELECTRON_PATH" ] && [ -d "$ELECTRON_PATH/bin" ]; then
|
|
||||||
export ELECTRON_OVERRIDE_DIST_PATH="$ELECTRON_PATH/bin"
|
|
||||||
echo "NixOS detected: Using electron from $ELECTRON_PATH/bin"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user