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): map Hyprland punctuation hotkeys to XKB keysyms (#1877)

Henry Sudb3f8c930b26
diff --git a/src/helpers/hyprlandShortcut.js b/src/helpers/hyprlandShortcut.js
index eb0ab55b7..80078ae37 100644
--- a/src/helpers/hyprlandShortcut.js
+++ b/src/helpers/hyprlandShortcut.js
@@ -38,12 +38,24 @@ const ELECTRON_TO_HYPRLAND_KEY = {
backquote: "grave",
"`": "grave",
" ": "space",
+ // Punctuation must be XKB names; a literal "," is the bind delimiter.
+ ",": "comma",
+ ".": "period",
+ "/": "slash",
+ "-": "minus",
+ "=": "equal",
+ ";": "semicolon",
+ "'": "apostrophe",
+ "[": "bracketleft",
+ "]": "bracketright",
+ "\\": "backslash",
+ plus: "plus",
};
// Valid Electron-format hotkey: optional modifiers joined by +, ending with a key
// Supports: standalone keys (F4, Space), modifier+key combos, and modifier-only combos (Control+Super)
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;
+ /^((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|`|,|\.|\/|-|=|;|'|\[|\]|\\|Plus)?$/i;
const BINDS_FILENAMES = {
conf: "openwhispr-binds.conf",
diff --git a/test/helpers/hyprlandShortcut.test.js b/test/helpers/hyprlandShortcut.test.js
index 63ad34a11..d68b16d84 100644
--- a/test/helpers/hyprlandShortcut.test.js
+++ b/test/helpers/hyprlandShortcut.test.js
@@ -416,3 +416,26 @@ test(
assert.equal(fs.readFileSync(confPath, "utf8"), "# keep this comment\n");
})
);
+
+test("punctuation accelerators validate and convert to XKB key names", () => {
+ const HyprlandShortcutManager = loadManager(() => "ok\n");
+
+ assert.equal(HyprlandShortcutManager.isValidHotkey("F8"), true);
+ assert.equal(HyprlandShortcutManager.isValidHotkey("Control+F8"), true);
+ assert.equal(HyprlandShortcutManager.isValidHotkey("Control+Super"), true);
+
+ assert.equal(HyprlandShortcutManager.isValidHotkey("Control+,"), true);
+ assert.equal(HyprlandShortcutManager.isValidHotkey("Alt+."), true);
+ assert.equal(HyprlandShortcutManager.isValidHotkey("Control+/"), true);
+ assert.equal(HyprlandShortcutManager.isValidHotkey("Control+-"), true);
+ assert.equal(HyprlandShortcutManager.isValidHotkey("Control+Plus"), true);
+
+ assert.equal(HyprlandShortcutManager.convertToHyprlandFormat("Control+,").bindKey, "CTRL, comma");
+ assert.equal(HyprlandShortcutManager.convertToHyprlandFormat("Alt+.").bindKey, "ALT, period");
+ assert.equal(HyprlandShortcutManager.convertToHyprlandFormat("Control+/").bindKey, "CTRL, slash");
+ assert.equal(HyprlandShortcutManager.convertToHyprlandFormat("Control+-").bindKey, "CTRL, minus");
+ assert.equal(
+ HyprlandShortcutManager.convertToHyprlandFormat("Control+Plus").bindKey,
+ "CTRL, plus"
+ );
+});