Skip to content

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

style: apply prettier formatting to helper modules

Gabriel Steinaf2bc140325c
diff --git a/src/helpers/clipboard.js b/src/helpers/clipboard.js
index 0d3d0e51e..c436d76f2 100644
--- a/src/helpers/clipboard.js
+++ b/src/helpers/clipboard.js
@@ -162,9 +162,7 @@ class ClipboardManager {
}
const possiblePaths = [
- ...(process.resourcesPath
- ? [path.join(process.resourcesPath, "bin", "nircmd.exe")]
- : []),
+ ...(process.resourcesPath ? [path.join(process.resourcesPath, "bin", "nircmd.exe")] : []),
path.join(__dirname, "..", "..", "resources", "bin", "nircmd.exe"),
path.join(process.cwd(), "resources", "bin", "nircmd.exe"),
];
diff --git a/src/helpers/hotkeyManager.js b/src/helpers/hotkeyManager.js
index 0b5f12983..96600ff25 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;
}
@@ -606,9 +608,7 @@ class HotkeyManager {
const success = await this.kdeManager.registerKeybinding(hotkey, "dictation", callback);
if (success) {
this.currentHotkey = hotkey;
- debugLogger.log(
- `[HotkeyManager] KDE hotkey "${hotkey}" registered successfully`
- );
+ debugLogger.log(`[HotkeyManager] KDE hotkey "${hotkey}" registered successfully`);
} else {
debugLogger.log(
"[HotkeyManager] KDE keybinding failed, falling back to globalShortcut"
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 8d6c32a19..100f98ffc 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -2487,7 +2487,13 @@ class IPCHandlers {
{ ref: "_meetingSystemStreaming", secret: secrets[1], source: "system" },
];
} else {
- pairs = [{ ref: "_meetingMicStreaming", secret: await fetchRealtimeToken(event, options), source: "mic" }];
+ pairs = [
+ {
+ ref: "_meetingMicStreaming",
+ secret: await fetchRealtimeToken(event, options),
+ source: "mic",
+ },
+ ];
}
for (const { ref, source } of pairs) {
diff --git a/src/helpers/kdeShortcut.js b/src/helpers/kdeShortcut.js
index 9ebf01864..e1d511030 100644
--- a/src/helpers/kdeShortcut.js
+++ b/src/helpers/kdeShortcut.js
@@ -25,23 +25,75 @@ const QT_MODIFIERS = {
};
const QT_KEYS = {
- a: 0x41, b: 0x42, c: 0x43, d: 0x44, e: 0x45, f: 0x46, g: 0x47, h: 0x48,
- i: 0x49, j: 0x4a, k: 0x4b, l: 0x4c, m: 0x4d, n: 0x4e, o: 0x4f, p: 0x50,
- q: 0x51, r: 0x52, s: 0x53, t: 0x54, u: 0x55, v: 0x56, w: 0x57, x: 0x58,
- y: 0x59, z: 0x5a,
- 0: 0x30, 1: 0x31, 2: 0x32, 3: 0x33, 4: 0x34,
- 5: 0x35, 6: 0x36, 7: 0x37, 8: 0x38, 9: 0x39,
- f1: 0x01000030, f2: 0x01000031, f3: 0x01000032, f4: 0x01000033,
- f5: 0x01000034, f6: 0x01000035, f7: 0x01000036, f8: 0x01000037,
- f9: 0x01000038, f10: 0x01000039, f11: 0x0100003a, f12: 0x0100003b,
- space: 0x20, tab: 0x01000001, escape: 0x01000000, backspace: 0x01000003,
- enter: 0x01000005, return: 0x01000004,
- insert: 0x01000006, delete: 0x01000007,
- home: 0x01000010, end: 0x01000011,
- pageup: 0x01000016, pagedown: 0x01000017,
- up: 0x01000013, down: 0x01000015, left: 0x01000012, right: 0x01000014,
- "`": 0x60, grave: 0x60,
- print: 0x01000009, scrolllock: 0x01000026, pause: 0x01000008,
+ a: 0x41,
+ b: 0x42,
+ c: 0x43,
+ d: 0x44,
+ e: 0x45,
+ f: 0x46,
+ g: 0x47,
+ h: 0x48,
+ i: 0x49,
+ j: 0x4a,
+ k: 0x4b,
+ l: 0x4c,
+ m: 0x4d,
+ n: 0x4e,
+ o: 0x4f,
+ p: 0x50,
+ q: 0x51,
+ r: 0x52,
+ s: 0x53,
+ t: 0x54,
+ u: 0x55,
+ v: 0x56,
+ w: 0x57,
+ x: 0x58,
+ y: 0x59,
+ z: 0x5a,
+ 0: 0x30,
+ 1: 0x31,
+ 2: 0x32,
+ 3: 0x33,
+ 4: 0x34,
+ 5: 0x35,
+ 6: 0x36,
+ 7: 0x37,
+ 8: 0x38,
+ 9: 0x39,
+ f1: 0x01000030,
+ f2: 0x01000031,
+ f3: 0x01000032,
+ f4: 0x01000033,
+ f5: 0x01000034,
+ f6: 0x01000035,
+ f7: 0x01000036,
+ f8: 0x01000037,
+ f9: 0x01000038,
+ f10: 0x01000039,
+ f11: 0x0100003a,
+ f12: 0x0100003b,
+ space: 0x20,
+ tab: 0x01000001,
+ escape: 0x01000000,
+ backspace: 0x01000003,
+ enter: 0x01000005,
+ return: 0x01000004,
+ insert: 0x01000006,
+ delete: 0x01000007,
+ home: 0x01000010,
+ end: 0x01000011,
+ pageup: 0x01000016,
+ pagedown: 0x01000017,
+ up: 0x01000013,
+ down: 0x01000015,
+ left: 0x01000012,
+ right: 0x01000014,
+ "`": 0x60,
+ grave: 0x60,
+ print: 0x01000009,
+ scrolllock: 0x01000026,
+ pause: 0x01000008,
};
const COMPONENT_NAME = "openwhispr";
@@ -92,10 +144,7 @@ class KDEShortcutManager {
try {
this.bus = dbusModule.sessionBus();
- const proxy = await this.bus.getProxyObject(
- "org.kde.kglobalaccel",
- "/kglobalaccel"
- );
+ const proxy = await this.bus.getProxyObject("org.kde.kglobalaccel", "/kglobalaccel");
this.kglobalaccel = proxy.getInterface("org.kde.KGlobalAccel");
debugLogger.log("[KDEShortcut] Connected to KGlobalAccel D-Bus");
@@ -113,10 +162,7 @@ class KDEShortcutManager {
try {
const componentPath = `/component/${COMPONENT_NAME}`;
- const proxy = await this.bus.getProxyObject(
- "org.kde.kglobalaccel",
- componentPath
- );
+ const proxy = await this.bus.getProxyObject("org.kde.kglobalaccel", componentPath);
const iface = proxy.getInterface("org.kde.kglobalaccel.Component");
iface.on("globalShortcutPressed", (componentUnique, shortcutUnique, timestamp) => {
@@ -124,12 +170,15 @@ class KDEShortcutManager {
// 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);
+ const callback =
+ this.callbacks.get(shortcutUnique) || this._findCallbackByFriendlyName(shortcutUnique);
if (callback) {
callback();
} else {
- debugLogger.log("[KDEShortcut] No callback found for", { shortcutUnique, registered: [...this.callbacks.keys()] });
+ debugLogger.log("[KDEShortcut] No callback found for", {
+ shortcutUnique,
+ registered: [...this.callbacks.keys()],
+ });
}
});
@@ -168,12 +217,7 @@ class KDEShortcutManager {
}
// actionId: [componentUnique, componentFriendly, actionUnique, actionFriendly]
- const actionId = [
- COMPONENT_NAME,
- "OpenWhispr",
- slotName,
- `OpenWhispr ${slotName}`,
- ];
+ const actionId = [COMPONENT_NAME, "OpenWhispr", slotName, `OpenWhispr ${slotName}`];
try {
// Register action then set shortcut
@@ -186,7 +230,9 @@ class KDEShortcutManager {
// Start listening for press events on the component
const listening = await this._listenForComponent();
if (!listening) {
- debugLogger.log(`[KDEShortcut] Keybinding registered but listener failed for "${slotName}"`);
+ debugLogger.log(
+ `[KDEShortcut] Keybinding registered but listener failed for "${slotName}"`
+ );
return false;
}
@@ -206,12 +252,7 @@ class KDEShortcutManager {
async unregisterKeybinding(slotName = "dictation") {
if (!this.kglobalaccel) return;
- const actionId = [
- COMPONENT_NAME,
- "OpenWhispr",
- slotName,
- `OpenWhispr ${slotName}`,
- ];
+ const actionId = [COMPONENT_NAME, "OpenWhispr", slotName, `OpenWhispr ${slotName}`];
try {
await this.kglobalaccel.unRegister(actionId);
@@ -237,7 +278,9 @@ class KDEShortcutManager {
Promise.allSettled(promises).finally(() => {
if (this.bus) {
- try { this.bus.disconnect(); } catch {}
+ try {
+ this.bus.disconnect();
+ } catch {}
this.bus = null;
this.kglobalaccel = null;
this.componentProxy = null;
diff --git a/src/helpers/meetingDetectionEngine.js b/src/helpers/meetingDetectionEngine.js
index e6aec1398..69bcdf806 100644
--- a/src/helpers/meetingDetectionEngine.js
+++ b/src/helpers/meetingDetectionEngine.js
@@ -202,7 +202,11 @@ class MeetingDetectionEngine {
}
} catch (error) {
this._meetingModeActive = false;
- debugLogger.error("Error handling notification response", { error: error?.message, detectionId, action }, "meeting");
+ debugLogger.error(
+ "Error handling notification response",
+ { error: error?.message, detectionId, action },
+ "meeting"
+ );
} finally {
this.windowManager.dismissMeetingNotification();
}