From cbbe779faa45b9c23c2f36aa19deafbc558ea0dd Mon Sep 17 00:00:00 2001 From: Avi Date: Mon, 24 Aug 2026 11:46:48 -0500 Subject: [PATCH] Desktop entry + Wayland app id so the taskbar shows the app icon --- frontend/electron/main.ts | 7 ++++ frontend/package.json | 1 + frontend/scripts/install-desktop-entry.sh | 42 +++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100755 frontend/scripts/install-desktop-entry.sh diff --git a/frontend/electron/main.ts b/frontend/electron/main.ts index dde0544..c0fe1f1 100644 --- a/frontend/electron/main.ts +++ b/frontend/electron/main.ts @@ -563,6 +563,13 @@ function createWindow(): void { }); } +// Wayland has no per-window icons: the taskbar resolves the running app's id +// through an installed .desktop file instead (see +// scripts/install-desktop-entry.sh). Pin the identity before `ready`. +if (process.platform === 'linux') { + app.setDesktopName('keynectr.desktop'); +} + app.whenReady().then(() => { protocol.handle('app', (request) => { const { pathname } = new URL(request.url); diff --git a/frontend/package.json b/frontend/package.json index 6dadc90..8ed1c4c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -17,6 +17,7 @@ "format:check": "prettier --check .", "electron:build": "tsc -p tsconfig.electron.json", "start": "npm run electron:build && electron .", + "desktop:install": "bash scripts/install-desktop-entry.sh", "dist": "npm run build && npm run electron:build && electron-builder --linux dir" }, "dependencies": { diff --git a/frontend/scripts/install-desktop-entry.sh b/frontend/scripts/install-desktop-entry.sh new file mode 100755 index 0000000..c2ceeb5 --- /dev/null +++ b/frontend/scripts/install-desktop-entry.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# Install the Keynectr .desktop entry and icon for the current user. +# +# On Linux (especially Wayland) the taskbar icon does not come from the +# BrowserWindow icon: the desktop environment resolves the running app's id +# against an installed .desktop file and its Icon= key. This script installs +# both so the hummingbird-key icon shows up in launchers and taskbars. +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +ICON_SRC="$ROOT/build/icon.png" +ICON_DIR="$HOME/.local/share/icons/hicolor/512x512/apps" +DESKTOP_DIR="$HOME/.local/share/applications" + +if [[ ! -f "$ICON_SRC" ]]; then + echo "Icon not found at $ICON_SRC" >&2 + exit 1 +fi + +mkdir -p "$ICON_DIR" "$DESKTOP_DIR" +cp "$ICON_SRC" "$ICON_DIR/keynectr.png" + +cat > "$DESKTOP_DIR/keynectr.desktop" </dev/null || true +command -v kbuildsycoca6 >/dev/null 2>&1 && kbuildsycoca6 --noincremental >/dev/null 2>&1 || true + +echo "Installed:" +echo " $ICON_DIR/keynectr.png" +echo " $DESKTOP_DIR/keynectr.desktop" +echo "Restart Keynectr to see the icon in the taskbar."