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): restore KDE Plasma hotkey and overlay window behavior

Gabriel Stein5db2aad7f2d9
diff --git a/main.js b/main.js
index 52106dc67..7dd354cb8 100644
--- a/main.js
+++ b/main.js
@@ -76,8 +76,8 @@ if (process.platform === "win32") {
}
// Enable native Wayland support: Ozone platform for native rendering.
-// KDE uses XWayland for reliable clipboard access (Wayland restricts clipboard
-// to focused windows), with KGlobalAccel D-Bus for global shortcuts.
+// 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.
if (process.platform === "linux" && process.env.XDG_SESSION_TYPE === "wayland") {
const desktop = (process.env.XDG_CURRENT_DESKTOP || "").toLowerCase();
diff --git a/src/helpers/hotkeyManager.js b/src/helpers/hotkeyManager.js
index 0b5f12983..39252ab3f 100644
--- a/src/helpers/hotkeyManager.js
+++ b/src/helpers/hotkeyManager.js
@@ -211,9 +211,7 @@ class HotkeyManager {
slot.accelerator = null;
this.slots.set(slotName, slot);
- debugLogger.log(
- `[HotkeyManager] KDE slot "${slotName}" set to "${hotkey}"`
- );
+ debugLogger.log(`[HotkeyManager] KDE slot "${slotName}" set to "${hotkey}"`);
return { success: true, hotkey };
}
@@ -483,7 +481,11 @@ class HotkeyManager {
}
async initializeKDEShortcuts(callback) {
- if (process.platform !== "linux" || !KDEShortcutManager.isWayland() || !KDEShortcutManager.isKDE()) {
+ if (
+ process.platform !== "linux" ||
+ !KDEShortcutManager.isWayland() ||
+ !KDEShortcutManager.isKDE()
+ ) {
return false;
}
@@ -593,49 +595,7 @@ class HotkeyManager {
return;
}
- // 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
+ // Try Hyprland native shortcuts if GNOME path was not applicable
const hyprlandOk = await this.initializeHyprlandShortcuts(callback);
if (hyprlandOk) {
@@ -748,6 +708,28 @@ 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) {
@@ -861,6 +843,28 @@ 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);
diff --git a/src/helpers/windowConfig.js b/src/helpers/windowConfig.js
index a59a77407..ea5d85e93 100644
--- a/src/helpers/windowConfig.js
+++ b/src/helpers/windowConfig.js
@@ -5,6 +5,20 @@ const isGnomeWayland =
process.env.XDG_SESSION_TYPE === "wayland" &&
/gnome|ubuntu|unity/i.test(process.env.XDG_CURRENT_DESKTOP || "");
+const isKDEWayland =
+ process.platform === "linux" &&
+ process.env.XDG_SESSION_TYPE === "wayland" &&
+ /kde/i.test(process.env.XDG_CURRENT_DESKTOP || "");
+
+const OVERLAY_WINDOW_TYPE =
+ process.platform === "darwin"
+ ? "panel"
+ : process.platform === "linux"
+ ? isGnomeWayland || isKDEWayland
+ ? "normal"
+ : "toolbar"
+ : "normal";
+
const WINDOW_SIZES = {
BASE: { width: 96, height: 96 },
WITH_MENU: { width: 240, height: 280 },
@@ -34,14 +48,7 @@ const MAIN_WINDOW_CONFIG = {
fullScreenable: false,
hasShadow: false,
acceptsFirstMouse: true,
- type:
- process.platform === "darwin"
- ? "panel"
- : process.platform === "linux"
- ? isGnomeWayland
- ? "normal"
- : "toolbar"
- : "normal",
+ type: OVERLAY_WINDOW_TYPE,
};
// Control panel window configuration
@@ -101,8 +108,7 @@ const NOTIFICATION_WINDOW_CONFIG = {
sandbox: true,
},
visibleOnAllWorkspaces: process.platform !== "win32",
- type:
- process.platform === "darwin" ? "panel" : process.platform === "linux" ? "toolbar" : "normal",
+ type: OVERLAY_WINDOW_TYPE,
};
class WindowPositionUtil {
@@ -153,7 +159,7 @@ class WindowPositionUtil {
}
} else if (process.platform === "win32") {
window.setAlwaysOnTop(true, "pop-up-menu");
- } else if (isGnomeWayland) {
+ } else if (isGnomeWayland || isKDEWayland) {
window.setAlwaysOnTop(true, "floating");
} else {
window.setAlwaysOnTop(true, "screen-saver");
@@ -178,8 +184,7 @@ const AGENT_OVERLAY_CONFIG = {
resizable: false,
fullScreenable: false,
acceptsFirstMouse: true,
- type:
- process.platform === "darwin" ? "panel" : process.platform === "linux" ? "toolbar" : "normal",
+ type: OVERLAY_WINDOW_TYPE,
visibleOnAllWorkspaces: process.platform !== "win32",
webPreferences: {
preload: path.join(__dirname, "..", "..", "preload.js"),