Repository navigation
Conversation
…creen Badges above the password field for Caps Lock, Num Lock off, a held Ctrl, Alt or Super, a non-default layout, and Shift while held. Hidden when there is nothing to say, so the stock lock screen looks the same as before. Caps Lock, Num Lock and the layout come from `hyprctl devices -j`, reduced by the new KeyboardStateModel.js and polled every 400 ms while the lock screen or its preview is up, plus on every key event the view sees, since Hyprland has no event for the lock keys. Virtual keyboards are ignored so an input method's own xkb state cannot mask the physical keyboards. Held modifiers are tracked from the view's own key events by xkb keycode rather than by Qt.Key: with shift:both_capslock_cancel in kb_options, a Shift release arrives as Qt.Key_CapsLock with Shift still set in event.modifiers, which left the SHIFT badge stuck when keyed off event.key. Any ordinary keypress resyncs the badges from its modifier flags. Requested in discussion omacom#6241 (originally omacom#1770) back when hyprlock drew the lock screen; the Quickshell lock never carried an indicator. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Automated AI review
Outcome: With two or more layouts configured, Super + Ctrl + L, idle and lid-close locks show a red badge for the default layout. Layout badge shows for the default layout
Suggested change: Name a keyboard's layout only when its Reproducer (fails at 0c36e2f)Save as #!/bin/bash
set -euo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
run_node_test <<'JS'
const model = requireFromRoot('shell/plugins/lock/KeyboardStateModel.js')
function devices(keyboards) {
return JSON.stringify({ mice: [], keyboards: keyboards })
}
// Two layouts configured (the manual's "us,dk" example, or the "us,<layout>"
// that default/hypr/input.lua writes for a non-Latin install), and the keyboard
// on the first one: omarchy-system-lock runs `hyprctl switchxkblayout all 0`
// before the lock screen shows, so this is the state at the start of every lock.
assertDeepEqual(
model.keyboardStateFromDevices(devices([
{ name: 'keychron', layout: 'us,dk', active_layout_index: 0, active_keymap: 'English (US)', capsLock: false, numLock: true, main: true }
])),
{ capsLockOn: false, numLockOn: true, layoutLabel: '' },
'the first (default) layout of a multi-layout config shows no layout badge'
)
JSActual output at the reviewed head (stdout empty, exit status 1):
Run with Node v26.7.0. The same test passes against a copy of the model that only names the layout when More findingsKeyboard poll keeps running while the lock is blankedThe 400 ms Suggested change: NUM LOCK OFF can stay lit (only with
|
The first layout of several no longer gets a badge. omarchy-system-lock switches every keyboard to its first layout, so with "us,dk" configured each lock opened with a red ENGLISH (US). The layout is now named only once a keyboard has moved off its first one. Power buttons, the lid switch and the video bus report as keyboards and keep their own xkb state. They are skipped like virtual keyboards, using the same list as the bar's KeyboardLayoutModel.js, so a Num Lock turned on at the keyboard clears NUM LOCK OFF and a layout switched at the lock is read from the keyboard that switched. A test holds the two lists together. AltGr no longer raises ALT: Right Alt is keycode 108 either way, but where the layout makes it AltGr it types password characters. The keyboard poll stops while the displays are blanked, when no badge can be seen, and reads again as soon as they wake. The model test now also checks that the key handlers, the focus reset and the key-triggered refresh are wired up. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Thanks, all four findings were right. Fixed in 83f9be1:
Tests: model cases for the default layout, a layout switched at the lock, and button devices; an AltGr case in the Quickshell fixture; and source assertions for Both new tests and the existing 🤖 Generated with Claude Code |
|
This conflicts with |
Summary
hyprctl devices -jthrough a smallKeyboardStateModel.js, polled every 400 ms while the lock screen or its preview is up and on every key event the view sees (Hyprland has no event for the lock keys). Virtual keyboards (hl-virtual-keyboard-*) are ignored so an input method's own xkb state cannot mask the physical keyboards.Qt.Key. With the defaultshift:both_capslock_cancela Shift release reaches Qt asQt.Key_CapsLockwith Shift still set inevent.modifiers, which leaves a SHIFT badge stuck if keyed offevent.key. Any ordinary keypress also resyncs the badges from its modifier flags.lock.*theme tokens (border-active/textfor Shift,border-error/text-errorfor everything else), so themes that already style the lock's error state get a matching badge for free.This is the request from discussion #6241 (originally #1770), which was answered for hyprlock. The Quickshell lock never carried an indicator, so a wrong-looking password today gives no hint that Caps Lock is on.
Verification
bash test/shell.d/lock-keyboard-state-model-test.sh(node: device parsing, virtual-keyboard exclusion, layout naming, malformed input; service wiring)bash test/shell.d/lock-keyboard-state-badges-test.sh(Quickshell fixture: badge row placement above the field, each badge, the Shift-release-as-CapsLock case, resync on an ordinary key)lock-fingerprint-indicator,lock-password-overflow,lock-blank-fingerprintandlock-wallpaper-preloadtests still passgit diff --checkNotes for review
hyprctl devices -jevery 400 ms only while locked or previewing, the same shape as the existing DPMS poll used for video wallpapers.NUM LOCK OFFreports any physical keyboard whose Num Lock is off. Omarchy enables Num Lock by default, so on a stock config the badge only appears after the user turned it off.LockView.qmlfor Clear and swallow the lock-screen wake key so it is not typed as a password character #11858, which touches theKeys.onPressedhandler and would merge cleanly with a trivial conflict.🤖 Generated with Claude Code