omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

input.numlock_by_default = true mangles letters into digits on Apple keyboards with no numpad (hid-apple keypad emulation)

Open cheekychops opened this issue 3 months ago • 5 comments

System details

  • CPU: Intel Core i5-3210M @ 2.50GHz
  • GPU: Intel HD Graphics 4000 (Ivy Bridge)
  • Machine: Apple Mac Mini (2012)
  • Omarchy: 4.0.1-1 (omarchy-settings 4.0.1-1)
  • Architecture: x86_64
  • Kernel: 7.1.9-arch1-2
  • Hyprland: 0.56.2-1
  • Keyboard: Apple Wireless Keyboard over Bluetooth, USB id 05ac:023a

What's wrong?

/usr/share/omarchy/default/hypr/input.lua:62 sets input.numlock_by_default = true for every keyboard.

hid-apple applies numeric-keypad emulation to Apple keyboards, including models that have no physical numpad. With numlock forced on at session start, the kernel overlays a phantom keypad onto the letter keys, so ordinary typing produces digits.

Typing some keys are not sending the correct characters on the Apple keyboard produces:

s60e 2eys are n6t send4ng the c6rrect characters

The substitutions are o -> 6, m -> 0, k -> 2, i -> 4. The affected keys are the ones hid-apple maps into its emulated keypad; the keyboard has no numpad to make use of it, so the overlay only destroys letters.

Steps to reproduce

  1. Connect an Apple keyboard that has no numeric keypad (here: Apple Wireless Keyboard, 05ac:023a, over Bluetooth).
  2. Confirm the Omarchy default is in effect - hyprctl devices shows numLock: yes for that keyboard, and /sys/class/leds/*numlock*/brightness reads 1.
  3. Type letters, including o, k, m, i.

Expected result

Letter keys produce letters. A keyboard with no numeric keypad should not have numlock forced on, since it can only misfire there.

Actual result

Letter keys produce digits, as above. The keyboard is unusable for typing until numlock is turned off.

Workaround

Scope numlock off to the affected device in ~/.config/hypr/input.lua, rather than disabling it globally (a global numlock_by_default = false would turn a real numpad into arrow keys):

hl.device({ name = "<name from hyprctl devices>", numlock_by_default = false })

Verified with hyprctl reload && hyprctl configerrors (clean). Afterwards hyprctl devices reports numLock: no for that device only, the numlock LED goes 1 -> 0, and typing is correct.

Notes

  • Closely related in spirit to #7110, where fnmode=2 is forced on every install and misfires on Apple keyboards. Both are global input defaults that assume non-Apple hardware.
  • This is the inverse of #8552, #7162 and #8176, which are all about NumLock being ignored so a numpad won't type digits. Here the problem is numlock being applied to a keyboard that has no numpad at all.

cheekychops avatar Aug 29 '26 09:08 cheekychops

Reproduced end to end, and your diagnosis holds. The reproduction ran on a disposable Omarchy 4.0.1 worker at your exact kernel (7.1.9-arch1-2), using a virtual Bluetooth HID keyboard created through /dev/uhid carrying the ids 05ac:023a — no Apple hardware involved, only the ids hid-apple matches on.

The chain. default/hypr/input.lua:62 sets numlock_by_default = true with no hardware gate, so Hyprland lights LED_NUML on every keyboard it sees. In the hid-apple.ko shipped with 7.1.9-arch1-2, the device entry for Bluetooth 05ac:023a carries driver_data = 0x114 — APPLE_NUMLOCK_EMULATION | APPLE_ISO_TILDE_QUIRK | APPLE_HAS_FN — and hidinput_apple_event() then translates through powerbook_numlock_keys[] whenever LED_NUML is set on that device. That happens in the kernel, above evdev, so no keyboard layout, compositor rule or application can undo it.

On the worker the running Omarchy session lit LED_NUML on the new keyboard within two seconds of it appearing — the probe never wrote the LED itself — and typing then gave:

o -> KEY_KP6    m -> KEY_KP0    i -> KEY_KP5

The lock screen and the polkit dialog are affected; the SDDM greeter and the LUKS prompt are not. With omarchy-system-lock engaged and omarchy-hyprland-session-locked reporting locked, the same keys still arrived as KEY_KP6 / KEY_KP0 / KEY_KP5. Any password containing u i o p j k l m 0 7 8 9 . / ; - is untypeable there, and the deny=10 unlock_time=120 in the lock's PAM stack adds a two-minute lockout after ten tries. The greeter is clear because its compositor runs from default/sddm/hyprland.lua, which has no input block at all, and nothing in the repo turns numlock on before the session starts — so you get in, and then the keyboard breaks. The realistic way to meet this is the idle lock, which fires after 300 seconds by default.

There is a way out, and it is worth knowing before you need it. The same kernel table maps F6 -> NUMLOCK, so pressing plain F6 while numlock is on emits NumLock and ends the overlay. Verified on the worker under both fnmode=1 and the fnmode=2 that Omarchy installs, because the numlock table is applied after the Fn table and catches KEY_F6 unconditionally while the LED is lit — no Fn needed. What is not verified is the physical F6 on your keyboard emitting HID usage 0x3f, and whether the compositor acts on NumLock while the lock surface holds keyboard focus. If you can press F6 at a lock screen once and say what happens, that settles the only thing this diagnosis still leaves open.

One correction. The kernel table maps i -> KP5, not KP4; u is the key that gives 4. Your pasted line reads send4ng where the mechanism predicts send5ng. That looks like a transcription slip rather than a second cause: o, m and k match exactly, and the per-device workaround fixing it settles the rest.

Why it shows up now. The setting is old — 73bc6159, first released in v2.1.1 — but it lived in config/hypr/input.conf, your own file, where deleting the line was enough. 2fdc6f05 moved it into default/hypr/input.lua for 4.0.0, where it applies to every install and can only be countered by an override like the one you wrote.

Not the same bug as its neighbours. #8552, #7162 and #8176 are the inverse and share only the setting: keypad keys failing to produce digits in Quickshell surfaces, at the Qt or XKB layer, with PRs #8018 and #8023 aimed at them. #8762 and #8924 are authentication-path failures where the keystrokes arrive intact. The closest relative is #7110 — same driver, same shape of ungated global default that assumes non-Apple hardware.

Whether to drop the default, gate it per device, or leave it is a decision about the product, so this is reported for the maintainer rather than patched here. One thing worth flagging for whoever takes it: detecting "has a keypad" from input capabilities will not work, because hid-apple advertises KEY_NUMLOCK and the whole translated keypad range on exactly these keypad-less keyboards.

Reviewed twice — by Claude Opus 5, which ran the reproduction above, and independently by Codex at xhigh reasoning, which read the upstream kernel source, agreed on the mechanism, reached the i -> KP5 correction on its own, and contributed the keypad-capability point. Codex could not check the quirk flags in the shipped 7.1.9 module and expected Fn+F6 rather than plain F6; both of those were settled on the worker.

omarchybot avatar Aug 29 '26 12:08 omarchybot

Confirming this on another affected model: a "Gemini IV" laptop, Intel Pentium Silver N5030, no separate physical numpad, running Omarchy 4.0.4-1.

Same symptom: with input.numlock_by_default = true (the Omarchy default), pressing M produced a dash (embedded Fn-numpad mapping M to a keypad key). It also interacted with #8552: the same keys typed nothing at all in hyprlock/polkit, making the lock screen effectively unenterable.

Setting numlock_by_default = false in ~/.config/hypr/input.lua fixed both issues at once. Worth considering a safer default for keyboards without a physical numpad, or at least surfacing this in the manual's troubleshooting section since it's not obvious the two bugs share a root cause.

Wesley971 avatar Sep 21 '26 00:09 Wesley971

Re-checked against the current quattro head (c352b62). Nothing has changed: default/hypr/input.lua:62 still sets numlock_by_default = true for every keyboard. Nothing in the repository excludes keyboards with an emulated or embedded keypad: no udev rule, hwdb entry, module option or Hyprland device rule. The reproduction from the earlier comment still applies to the current code.

What is new since that comment:

  • The same trigger on non-Apple hardware. @Wesley971's laptop has an embedded Fn-numpad and no hid-apple. Turning NumLock off fixed it, which fits the same cause: the forced default switches on a keypad overlay that is built into the keyboard. Their report alone does not show the evdev keycodes, and M giving a dash does not match Apple's M -> KP0 table, so this part is plausible, not reproduced. It does mean a fix that only targets Apple keyboards would not cover every affected machine.
  • #11369 reported the same problem on an A1314 Magic Keyboard (05ac:0255) and was closed in favour of this issue.
  • Open PR #12536 would carry this to the login screen. It adds numlock_by_default = true to default/sddm/hyprland.lua. Today the SDDM greeter is the one place these keyboards still type correctly, because it has no NumLock setting. With that change, letters would turn into digits while typing the login password, before any per-device override in ~/.config/hypr has loaded.

On a fix, no option is purely a defect correction. Every one of them changes behaviour for someone:

  • Dropping the default fixes both cases above, but every keyboard with a real numpad loses digits at session start.
  • A per-device exception is contained but needs a maintained list of affected models. It cannot be detected automatically, because hid-apple advertises the whole keypad range on keyboards that have no keypad.
  • hid_apple fnmode=0 turns off the emulation, but it also turns off every Fn translation on Apple keyboards, and it does nothing for embedded laptop keypads.

That decision belongs to the maintainer, so no fix PR is opened here. Until then, the per-device override in the issue body is the safe workaround.

Reviewed by Claude Opus 5.5 and independently by Codex at medium effort. Codex agreed the mechanism is unchanged on quattro and found no older open issue with the same cause. It also contributed the fnmode=0 trade-off and pointed out that removing the default only affects keyboards when they connect, so a session that is already running keeps NumLock on until it is toggled. Independence is not guaranteed. This is waiting on the maintainer.

omarchybot avatar Oct 09 '26 07:10 omarchybot

Another non-Apple data point: an Acer Switch 3 (SW312-31) with its detachable keyboard (Chicony ACER Tablet Keyboard), which has a numpad embedded in the letter keys. On Omarchy 4.5.0 with the default numlock_by_default = true, J, K and L type 1, 2 and 3 after login. numlock_by_default = false in ~/.config/hypr/input.lua fixes it.

jamescazzetta avatar Nov 06 '26 18:11 jamescazzetta

@jamescazzetta's Acer Switch 3 report adds another non-Apple keyboard with an embedded keypad: J/K/L become 1/2/3 after login, and disabling NumLock resolves it on that machine. This supports keeping non-Apple keyboards in scope; an Apple-only exception would miss this case. The Acer's driver and event codes have not been established.

On current quattro (c6be7abb9e518edc40f81be1b8ea0008e9b8b790), default/hypr/input.lua:77 still sets numlock_by_default = true globally, with user overrides loaded afterward. There is now an open candidate, #17675, which changes that default to false. By source reading, it removes the startup trigger described here, including the Acer case. It also changes startup behavior for physical numpads, whose users would need to enable NumLock or opt in through their input overrides. That choice remains with the maintainer, so no competing fix was opened.

The automatic fixing link to #17675 was refused because that pull request has not yet been classified as a fix. Its separate review still needs to establish the fix; this pass did not run tests or reproduce either the Acer hardware behavior or the candidate's behavior on a worker.

GPT-6 High in Codex reviewed the current configuration, load order, new report and candidate diff. Opus 5.5 High and muse-wonder via pi, thinking high, agreed with the source analysis and the remaining trade-off; independence is not guaranteed. This issue is waiting on the maintainer's decision about the default.

omarchybot avatar Nov 18 '26 02:11 omarchybot