Skip to content

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

add hotkey validation and scope wl-copy timeout to Hyprland

Alcahest2af74f0ae57d
diff --git a/src/helpers/clipboard.js b/src/helpers/clipboard.js
index 643427234..43fc03403 100644
--- a/src/helpers/clipboard.js
+++ b/src/helpers/clipboard.js
@@ -91,7 +91,8 @@ class ClipboardManager {
_writeClipboardWayland(text, webContents) {
if (this.commandExists("wl-copy")) {
try {
- const result = spawnSync("wl-copy", ["--", text], { timeout: 50 });
+ const isHyprland = !!process.env.HYPRLAND_INSTANCE_SIGNATURE;
+ const result = spawnSync("wl-copy", ["--", text], { timeout: isHyprland ? 50 : 1 });
if (result.status === 0) {
clipboard.writeText(text);
return;
diff --git a/src/helpers/hyprlandShortcut.js b/src/helpers/hyprlandShortcut.js
index e35f5d99f..653743878 100644
--- a/src/helpers/hyprlandShortcut.js
+++ b/src/helpers/hyprlandShortcut.js
@@ -37,6 +37,11 @@ const ELECTRON_TO_HYPRLAND_KEY = {
" ": "space",
};
+// Valid Electron-format hotkey: modifiers joined by +, ending with an optional key
+// Supports: letters, digits, function keys (F1-F24), navigation, special keys, and modifier-only combos
+const VALID_HOTKEY_PATTERN =
+ /^(CommandOrControl|CmdOrCtrl|Control|Ctrl|Alt|Option|Shift|Super|Meta|Win|Command|Cmd)(\+(CommandOrControl|CmdOrCtrl|Control|Ctrl|Alt|Option|Shift|Super|Meta|Win|Command|Cmd))*(\+(F([1-9]|1[0-9]|2[0-4])|[A-Za-z0-9]|Space|Escape|Tab|Backspace|Delete|Insert|Home|End|PageUp|PageDown|ArrowUp|ArrowDown|ArrowLeft|ArrowRight|Enter|PrintScreen|ScrollLock|Pause|Backquote|`))?$/i;
+
let dbus = null;
function getDBus() {
@@ -142,6 +147,13 @@ class HyprlandShortcutManager {
return OpenWhisprInterface;
}
+ static isValidHotkey(hotkey) {
+ if (!hotkey || typeof hotkey !== "string") {
+ return false;
+ }
+ return VALID_HOTKEY_PATTERN.test(hotkey);
+ }
+
/**
* Convert an Electron-format hotkey string to Hyprland bind format.
*
@@ -229,6 +241,11 @@ class HyprlandShortcutManager {
return false;
}
+ if (!HyprlandShortcutManager.isValidHotkey(hotkey)) {
+ debugLogger.log(`[HyprlandShortcut] Invalid hotkey format: "${hotkey}"`);
+ return false;
+ }
+
const converted = HyprlandShortcutManager.convertToHyprlandFormat(hotkey);
if (!converted) {
debugLogger.log(`[HyprlandShortcut] Could not convert hotkey "${hotkey}" to Hyprland format`);