Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix(linux): revert hotkeyManager.js changes, keep KDE D-Bus as primary

Gabriel Stein811d55c98028
diff --git a/main.js b/main.js
index 7dd354cb8..e7a5f2fd1 100644
--- a/main.js
+++ b/main.js
@@ -76,9 +76,9 @@ if (process.platform === "win32") {
}
// Enable native Wayland support: Ozone platform for native rendering.
-// KDE uses XWayland for reliable clipboard access and hotkey registration
-// (globalShortcut primary, KGlobalAccel D-Bus fallback).
-// GNOME and Hyprland run native Wayland with their own D-Bus shortcut managers.
+// KDE uses XWayland for reliable clipboard access, with KGlobalAccel D-Bus
+// for global shortcuts. GNOME and Hyprland run native Wayland with their
+// own D-Bus shortcut managers.
if (process.platform === "linux" && process.env.XDG_SESSION_TYPE === "wayland") {
const desktop = (process.env.XDG_CURRENT_DESKTOP || "").toLowerCase();
if (desktop.includes("kde")) {
diff --git a/src/helpers/hotkeyManager.js b/src/helpers/hotkeyManager.js
index 39252ab3f..96600ff25 100644
--- a/src/helpers/hotkeyManager.js
+++ b/src/helpers/hotkeyManager.js
@@ -595,7 +595,47 @@ class HotkeyManager {
return;
}
- // Try Hyprland native shortcuts if GNOME path was not applicable
+ // Try KDE native shortcuts via KGlobalAccel
+ const kdeOk = await this.initializeKDEShortcuts(callback);
+
+ if (kdeOk) {
+ const registerKDEHotkey = async () => {
+ try {
+ const savedHotkey = await mainWindow.webContents.executeJavaScript(`
+ localStorage.getItem("dictationKey") || ""
+ `);
+ const hotkey = savedHotkey && savedHotkey.trim() !== "" ? savedHotkey : "Control+Super";
+ const success = await this.kdeManager.registerKeybinding(hotkey, "dictation", callback);
+ if (success) {
+ this.currentHotkey = hotkey;
+ debugLogger.log(`[HotkeyManager] KDE hotkey "${hotkey}" registered successfully`);
+ } else {
+ debugLogger.log(
+ "[HotkeyManager] KDE keybinding failed, falling back to globalShortcut"
+ );
+ this.kdeManager.close();
+ this.kdeManager = null;
+ this.useKDE = false;
+ this.loadSavedHotkeyOrDefault(mainWindow, callback);
+ }
+ } catch (err) {
+ debugLogger.log(
+ "[HotkeyManager] KDE keybinding failed, falling back to globalShortcut:",
+ err.message
+ );
+ this.kdeManager?.close();
+ this.kdeManager = null;
+ this.useKDE = false;
+ this.loadSavedHotkeyOrDefault(mainWindow, callback);
+ }
+ };
+
+ setTimeout(registerKDEHotkey, HOTKEY_REGISTRATION_DELAY_MS);
+ this.isInitialized = true;
+ return;
+ }
+
+ // Try Hyprland native shortcuts if GNOME/KDE paths were not applicable
const hyprlandOk = await this.initializeHyprlandShortcuts(callback);
if (hyprlandOk) {
@@ -708,28 +748,6 @@ class HotkeyManager {
}
}
- // KDE D-Bus fallback — only reached when globalShortcut failed on XWayland
- const kdeOk = await this.initializeKDEShortcuts(callback);
- if (kdeOk) {
- const savedHotkey = process.env.DICTATION_KEY || defaultHotkey;
- const success = await this.kdeManager.registerKeybinding(
- savedHotkey,
- "dictation",
- callback
- );
- if (success) {
- this.currentHotkey = savedHotkey;
- debugLogger.log(
- `[HotkeyManager] KDE D-Bus fallback hotkey "${savedHotkey}" registered successfully`
- );
- return;
- }
- debugLogger.log("[HotkeyManager] KDE D-Bus fallback registration also failed");
- this.kdeManager.close();
- this.kdeManager = null;
- this.useKDE = false;
- }
-
debugLogger.log("[HotkeyManager] All hotkey fallbacks failed");
this.notifyHotkeyFailure(defaultHotkey, result);
} catch (err) {
@@ -843,28 +861,6 @@ class HotkeyManager {
};
}
- if (this.useKDE && this.kdeManager) {
- debugLogger.log(`[HotkeyManager] Updating KDE hotkey to "${hotkey}"`);
- const success = await this.kdeManager.registerKeybinding(hotkey, "dictation", callback);
- if (!success) {
- return {
- success: false,
- message: `Failed to update KDE hotkey to "${hotkey}". Check the format is valid.`,
- };
- }
- this.currentHotkey = hotkey;
- const saved = await this.saveHotkeyToRenderer(hotkey);
- if (!saved) {
- debugLogger.warn(
- "[HotkeyManager] KDE hotkey registered but failed to persist to localStorage"
- );
- }
- return {
- success: true,
- message: `Hotkey updated to: ${hotkey} (via KDE D-Bus shortcut)`,
- };
- }
-
const result = this.setupShortcuts(hotkey, callback);
if (result.success) {
const saved = await this.saveHotkeyToRenderer(hotkey);