aboutsummaryrefslogtreecommitdiffstats
path: root/keybinds
diff options
context:
space:
mode:
Diffstat (limited to 'keybinds')
-rw-r--r--keybinds/Binds.js10
-rw-r--r--keybinds/test_binds.js2
2 files changed, 11 insertions, 1 deletions
diff --git a/keybinds/Binds.js b/keybinds/Binds.js
index 1f809cf..604a53d 100644
--- a/keybinds/Binds.js
+++ b/keybinds/Binds.js
@@ -42,8 +42,16 @@ const NAMES = Object.assign(Object.create(null), {
"XF86Search": "Fn+F11",
});
+// Hyprland 0.56.2 reports a Lua `code:N` bind with key "" and keycode 0, so
+// such a bind is named here by its description.
+// ponytail: one entry per keycode bind; a new `code:` bind needs a line here.
+const UNNAMED = Object.assign(Object.create(null), {
+ "Desktop: Companion": "\\", // code:49, left of 1
+});
+
function keys(bind) {
- return mods(bind.modmask).concat([NAMES[bind.key] ?? bind.key]).join(" + ");
+ const k = bind.key || UNNAMED[bind.description] || "?";
+ return mods(bind.modmask).concat([NAMES[k] ?? k]).join(" + ");
}
// Where a bind sits on the macropad, keyed by the combo as keys() writes it,
diff --git a/keybinds/test_binds.js b/keybinds/test_binds.js
index df1e4b5..7b2289a 100644
--- a/keybinds/test_binds.js
+++ b/keybinds/test_binds.js
@@ -27,6 +27,8 @@ assert.strictEqual(B.keys({ modmask: 69, key: "F1" }), "Win + CTRL + SHIFT + F1"
assert.strictEqual(B.keys({ modmask: 0, key: "XF86AudioMute" }), "Mute");
assert.strictEqual(B.keys({ modmask: 64, key: "mouse:272" }), "Win + LMB");
assert.strictEqual(B.keys({ modmask: 0, key: "F5" }), "F5");
+// A keycode bind reports no key at all; it is named by its description.
+assert.strictEqual(B.keys({ modmask: 64, key: "", keycode: 0, description: "Desktop: Companion" }), "Win + \\");
// A key named like an Object.prototype member is not renamed.
assert.strictEqual(B.keys({ modmask: 0, key: "constructor" }), "constructor");