Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
Address review feedback on KDE shortcut manager
Alcahest0c65ecc23b3b
diff --git a/src/helpers/hotkeyManager.js b/src/helpers/hotkeyManager.jsindex 5c042965f..0b5f12983 100644--- a/src/helpers/hotkeyManager.js+++ b/src/helpers/hotkeyManager.js@@ -613,6 +613,8 @@ class HotkeyManager {debugLogger.log("[HotkeyManager] KDE keybinding failed, falling back to globalShortcut");+ this.kdeManager.close();+ this.kdeManager = null;this.useKDE = false;this.loadSavedHotkeyOrDefault(mainWindow, callback);}@@ -621,6 +623,8 @@ class HotkeyManager {"[HotkeyManager] KDE keybinding failed, falling back to globalShortcut:",err.message);+ this.kdeManager?.close();+ this.kdeManager = null;this.useKDE = false;this.loadSavedHotkeyOrDefault(mainWindow, callback);}diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex 1aa0f66cb..339bf5229 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -1384,7 +1384,7 @@ class IPCHandlers {return {isUsingGnome: this.windowManager.isUsingGnomeHotkeys(),isUsingHyprland: this.windowManager.isUsingHyprlandHotkeys(),- isUsingKDE: this.windowManager.isUsingKDEHotkeys?.() || false,+ isUsingKDE: this.windowManager.isUsingKDEHotkeys(),isUsingNativeShortcut: this.windowManager.isUsingNativeShortcutHotkeys(),};});@@ -3355,13 +3355,15 @@ class IPCHandlers {ipcMain.handle("get-ydotool-status", () => {const { getYdotoolStatus } = require("./ensureYdotool");- const status = getYdotoolStatus();const { execFileSync } = require("child_process");+ const status = getYdotoolStatus();const isKde = (process.env.XDG_CURRENT_DESKTOP || "").toLowerCase().includes("kde");let hasXclip = false;let hasXsel = false;- try { execFileSync("which", ["xclip"], { timeout: 1000 }); hasXclip = true; } catch {}- try { execFileSync("which", ["xsel"], { timeout: 1000 }); hasXsel = true; } catch {}+ if (isKde) {+ try { execFileSync("which", ["xclip"], { timeout: 1000 }); hasXclip = true; } catch {}+ try { execFileSync("which", ["xsel"], { timeout: 1000 }); hasXsel = true; } catch {}+ }return { ...status, isKde, hasXclip, hasXsel };});diff --git a/src/helpers/kdeShortcut.js b/src/helpers/kdeShortcut.jsindex 1746bffd6..9ebf01864 100644--- a/src/helpers/kdeShortcut.js+++ b/src/helpers/kdeShortcut.js@@ -109,7 +109,7 @@ class KDEShortcutManager {}async _listenForComponent() {- if (this.componentProxy) return;+ if (this.componentProxy) return true;try {const componentPath = `/component/${COMPONENT_NAME}`;@@ -121,7 +121,9 @@ class KDEShortcutManager {iface.on("globalShortcutPressed", (componentUnique, shortcutUnique, timestamp) => {debugLogger.log("[KDEShortcut] Shortcut pressed", { componentUnique, shortcutUnique });- // KGlobalAccel may send actionUnique or actionFriendly depending on version+ // Tested on KDE Plasma 6 (Fedora 43): signal sends the actionFriendly+ // name ("OpenWhispr") not the actionUnique ("dictation"). The fallback+ // maps friendly names back to slot names.const callback = this.callbacks.get(shortcutUnique)|| this._findCallbackByFriendlyName(shortcutUnique);if (callback) {@@ -133,8 +135,10 @@ class KDEShortcutManager {this.componentProxy = iface;debugLogger.log("[KDEShortcut] Listening for globalShortcutPressed on", componentPath);+ return true;} catch (err) {debugLogger.log("[KDEShortcut] Failed to listen on component:", err.message);+ return false;}}@@ -180,7 +184,11 @@ class KDEShortcutManager {this.registeredSlots.add(slotName);// Start listening for press events on the component- await this._listenForComponent();+ const listening = await this._listenForComponent();+ if (!listening) {+ debugLogger.log(`[KDEShortcut] Keybinding registered but listener failed for "${slotName}"`);+ return false;+ }debugLogger.log("[KDEShortcut] Registered", {slot: slotName,@@ -216,20 +224,26 @@ class KDEShortcutManager {}close() {- // Unregister all before closing+ // Best-effort cleanup on app shutdown. unRegister calls are async D-Bus+ // calls that may not complete before disconnect, but KGlobalAccel will+ // clean up stale registrations from dead processes anyway.+ const promises = [];for (const slotName of this.registeredSlots) {const actionId = [COMPONENT_NAME, "OpenWhispr", slotName, `OpenWhispr ${slotName}`];try {- this.kglobalaccel?.unRegister(actionId);+ promises.push(this.kglobalaccel?.unRegister(actionId));} catch {}}- if (this.bus) {- try { this.bus.disconnect(); } catch {}- this.bus = null;- this.kglobalaccel = null;- this.componentProxy = null;- }+ Promise.allSettled(promises).finally(() => {+ if (this.bus) {+ try { this.bus.disconnect(); } catch {}+ this.bus = null;+ this.kglobalaccel = null;+ this.componentProxy = null;+ }+ });+this.callbacks.clear();this.registeredSlots.clear();}