Keybindings menu test fixtures follow localization

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QKxGW1raAWaqeU8WdHsMsp
This commit is contained in:
2026-08-25 11:16:37 -04:00
co-authored by Claude Fable 5
parent e32f1eca8e
commit b85a998404
+38 -38
View File
@@ -50,24 +50,24 @@ keybindings() {
# binds twice on purpose. The last bind carries the longest description Omarchy # binds twice on purpose. The last bind carries the longest description Omarchy
# ships, which is what puts a row closest to the width the menu allows. # ships, which is what puts a row closest to the width the menu allows.
stub_hyprctl <<BINDS stub_hyprctl <<BINDS
$(lua_bind 64 "SUPER + W" "Close window") $(lua_bind 64 "SUPER + W" "关闭窗口")
$(lua_bind 64 "SUPER + Q" "Close window") $(lua_bind 64 "SUPER + Q" "关闭窗口")
$(lua_bind 64 "SUPER + F" "Full screen") $(lua_bind 64 "SUPER + F" "全屏")
$(lua_bind 64 "SUPER + S" "Toggle scratchpad") $(lua_bind 64 "SUPER + S" "切换便签区")
$(lua_bind 64 "SUPER + grave" "Toggle scratchpad") $(lua_bind 64 "SUPER + grave" "切换便签区")
$(exec_bind 73 "SUPER SHIFT ALT + 0" "Move window silently to workspace 10" "true") $(exec_bind 73 "SUPER SHIFT ALT + 0" "窗口静默移到工作区 10" "true")
BINDS BINDS
rendered=$(keybindings) rendered=$(keybindings)
[[ -n $rendered ]] || fail "the keybindings menu renders with a stubbed Hyprland" [[ -n $rendered ]] || fail "the keybindings menu renders with a stubbed Hyprland"
grep -q 'SUPER + F *→ Full screen' <<<"$rendered" || grep -q 'SUPER + F *→ 全屏' <<<"$rendered" ||
fail "a chord with no alternative renders on its own" "$rendered" fail "a chord with no alternative renders on its own" "$rendered"
pass "the keybindings menu renders its entries" pass "the keybindings menu renders its entries"
(( $(grep -c '→ Close window$' <<<"$rendered") == 1 )) || (( $(grep -c '→ 关闭窗口$' <<<"$rendered") == 1 )) ||
fail "an alternative chord joins the row of the first one" "$rendered" fail "an alternative chord joins the row of the first one" "$rendered"
grep -q 'SUPER + W / SUPER + Q *→ Close window' <<<"$rendered" || grep -q 'SUPER + W / SUPER + Q *→ 关闭窗口' <<<"$rendered" ||
fail "a shared row names both chords" "$rendered" fail "a shared row names both chords" "$rendered"
pass "an alternative chord joins the row of the first one" pass "an alternative chord joins the row of the first one"
@@ -78,7 +78,7 @@ grep -q '^SUPER + W / SUPER + Q' <<<"$rendered" ||
pass "the chord declared first leads a shared row" pass "the chord declared first leads a shared row"
# Hyprland calls the key left of 1 "grave". Nobody reads their keyboard that way. # Hyprland calls the key left of 1 "grave". Nobody reads their keyboard that way.
grep -q 'SUPER + S / SUPER + ~ *→ Toggle scratchpad' <<<"$rendered" || grep -q 'SUPER + S / SUPER + ~ *→ 切换便签区' <<<"$rendered" ||
fail "the grave key reads as the symbol printed on it" "$rendered" fail "the grave key reads as the symbol printed on it" "$rendered"
! grep -q 'grave' <<<"$rendered" || ! grep -q 'grave' <<<"$rendered" ||
fail "no entry still says grave" "$rendered" fail "no entry still says grave" "$rendered"
@@ -101,14 +101,14 @@ pass "no entry outgrows the width the menu gives it"
# the entry: XF86Calculator alone belongs in the tail the menu keeps for media # the entry: XF86Calculator alone belongs in the tail the menu keeps for media
# keys, while the calculator itself sits in the body of the list. # keys, while the calculator itself sits in the body of the list.
stub_hyprctl <<BINDS stub_hyprctl <<BINDS
$(exec_bind 68 "SUPER CTRL + Q" "Calculator" "omacalc") $(exec_bind 68 "SUPER CTRL + Q" "计算器" "omacalc")
$(exec_bind 0 "XF86Calculator" "Calculator" "omacalc") $(exec_bind 0 "XF86Calculator" "计算器" "omacalc")
$(exec_bind 8 "ALT + TAB" "Reveal active window on top" "true") $(exec_bind 8 "ALT + TAB" "活动窗口置顶显示" "true")
BINDS BINDS
rendered=$(keybindings) rendered=$(keybindings)
(( $(grep -n '→ Calculator$' <<<"$rendered" | cut -d: -f1) < (( $(grep -n '→ 计算器$' <<<"$rendered" | cut -d: -f1) <
$(grep -n '→ Reveal active window on top$' <<<"$rendered" | cut -d: -f1) )) || $(grep -n '→ 活动窗口置顶显示$' <<<"$rendered" | cut -d: -f1) )) ||
fail "a shared chord does not change where its entry ranks" "$rendered" fail "a shared chord does not change where its entry ranks" "$rendered"
pass "a shared chord does not change where its entry ranks" pass "a shared chord does not change where its entry ranks"
@@ -121,51 +121,51 @@ bind
key: key:
keycode: 49 keycode: 49
catchall: false catchall: false
description: Toggle scratchpad description: 切换便签区
dispatcher: exec dispatcher: exec
arg: true arg: true
BINDS BINDS
rendered=$(keybindings) rendered=$(keybindings)
grep -q 'SUPER + ~ *→ Toggle scratchpad' <<<"$rendered" || grep -q 'SUPER + ~ *→ 切换便签区' <<<"$rendered" ||
fail "a keycode resolves to the symbol printed on the key too" "$rendered" fail "a keycode resolves to the symbol printed on the key too" "$rendered"
pass "a keycode resolves to the symbol printed on the key too" pass "a keycode resolves to the symbol printed on the key too"
# A chord refused for width opens a row of its own, and the next chord tries # A chord refused for width opens a row of its own, and the next chord tries
# that row rather than reaching back past it and printing out of order. # that row rather than reaching back past it and printing out of order.
stub_hyprctl <<BINDS stub_hyprctl <<BINDS
$(exec_bind 64 "SUPER + A" "Calculator" "omacalc") $(exec_bind 64 "SUPER + A" "计算器" "omacalc")
$(exec_bind 77 "SUPER SHIFT CTRL ALT + BACKSPACE" "Calculator" "omacalc") $(exec_bind 77 "SUPER SHIFT CTRL ALT + BACKSPACE" "计算器" "omacalc")
$(exec_bind 64 "SUPER + B" "Calculator" "omacalc") $(exec_bind 64 "SUPER + B" "计算器" "omacalc")
BINDS BINDS
rendered=$(keybindings) rendered=$(keybindings)
(( $(grep -c '→ Calculator$' <<<"$rendered") == 3 )) || (( $(grep -c '→ 计算器$' <<<"$rendered") == 3 )) ||
fail "a refused chord does not let the next one jump the queue" "$rendered" fail "a refused chord does not let the next one jump the queue" "$rendered"
pass "a refused chord does not let the next one jump the queue" pass "a refused chord does not let the next one jump the queue"
# Sharing a row is something Omarchy names an action for, not something two # Sharing a row is something Omarchy names an action for, not something two
# chords earn by looking alike. Alt + Tab and Shift + Alt + Tab both read # chords earn by looking alike. Alt + Tab and Shift + Alt + Tab both read
# "Reveal active window on top" and cycle opposite ways. # "活动窗口置顶显示" and cycle opposite ways.
stub_hyprctl <<BINDS stub_hyprctl <<BINDS
$(exec_bind 64 "SUPER + Y" "Zoom in" "omarchy-zoom in") $(exec_bind 64 "SUPER + Y" "放大" "omarchy-zoom in")
$(exec_bind 64 "SUPER + Z" "Zoom in" "omarchy-zoom in") $(exec_bind 64 "SUPER + Z" "放大" "omarchy-zoom in")
BINDS BINDS
rendered=$(keybindings) rendered=$(keybindings)
(( $(grep -c '→ Zoom in$' <<<"$rendered") == 2 )) || (( $(grep -c '→ 放大$' <<<"$rendered") == 2 )) ||
fail "an action Omarchy did not name keeps its chords on separate rows" "$rendered" fail "an action Omarchy did not name keeps its chords on separate rows" "$rendered"
pass "an action Omarchy did not name keeps its chords on separate rows" pass "an action Omarchy did not name keeps its chords on separate rows"
# Even a named action gives up the shared row rather than overrun the column: # Even a named action gives up the shared row rather than overrun the column:
# two rows in line beat one that juts out of it. # two rows in line beat one that juts out of it.
stub_hyprctl <<BINDS stub_hyprctl <<BINDS
$(exec_bind 73 "SUPER SHIFT ALT + BACKSPACE" "Calculator" "omacalc") $(exec_bind 73 "SUPER SHIFT ALT + BACKSPACE" "计算器" "omacalc")
$(exec_bind 69 "SUPER SHIFT CTRL + BACKSPACE" "Calculator" "omacalc") $(exec_bind 69 "SUPER SHIFT CTRL + BACKSPACE" "计算器" "omacalc")
BINDS BINDS
rendered=$(keybindings) rendered=$(keybindings)
(( $(grep -c '→ Calculator$' <<<"$rendered") == 2 )) || (( $(grep -c '→ 计算器$' <<<"$rendered") == 2 )) ||
fail "chords too wide to share a row stay on their own" "$rendered" fail "chords too wide to share a row stay on their own" "$rendered"
[[ $(awk -F '→' '{ print length($1) }' <<<"$rendered" | sort -u) == "36" ]] || [[ $(awk -F '→' '{ print length($1) }' <<<"$rendered" | sort -u) == "36" ]] ||
fail "chords too wide to share a row leave the column alone" "$rendered" fail "chords too wide to share a row leave the column alone" "$rendered"
@@ -174,24 +174,24 @@ pass "chords too wide to share a row stay on their own"
# A shared label is not a shared action. Two chords that merely read alike have # A shared label is not a shared action. Two chords that merely read alike have
# to stay apart, or the menu hides one of them behind the other. # to stay apart, or the menu hides one of them behind the other.
stub_hyprctl <<BINDS stub_hyprctl <<BINDS
$(lua_bind 64 "SUPER + W" "Close window") $(lua_bind 64 "SUPER + W" "关闭窗口")
$(exec_bind 64 "SUPER + X" "Close window" "omarchy-hyprland-window-close-all") $(exec_bind 64 "SUPER + X" "关闭窗口" "omarchy-hyprland-window-close-all")
BINDS BINDS
rendered=$(keybindings) rendered=$(keybindings)
(( $(grep -c '→ Close window$' <<<"$rendered") == 2 )) || (( $(grep -c '→ 关闭窗口$' <<<"$rendered") == 2 )) ||
fail "chords with the same label but different actions stay apart" "$rendered" fail "chords with the same label but different actions stay apart" "$rendered"
pass "chords with the same label but different actions stay apart" pass "chords with the same label but different actions stay apart"
# An unresolved Lua bind reports no dispatcher at all, so nothing says the two # An unresolved Lua bind reports no dispatcher at all, so nothing says the two
# chords run the same thing, whatever their label promises. # chords run the same thing, whatever their label promises.
stub_hyprctl <<BINDS stub_hyprctl <<BINDS
$(lua_bind 64 "SUPER + Y" "Close window") $(lua_bind 64 "SUPER + Y" "关闭窗口")
$(lua_bind 64 "SUPER + Z" "Close window") $(lua_bind 64 "SUPER + Z" "关闭窗口")
BINDS BINDS
rendered=$(keybindings) rendered=$(keybindings)
(( $(grep -c '→ Close window$' <<<"$rendered") == 2 )) || (( $(grep -c '→ 关闭窗口$' <<<"$rendered") == 2 )) ||
fail "chords whose dispatch is unknown stay apart" "$rendered" fail "chords whose dispatch is unknown stay apart" "$rendered"
pass "chords whose dispatch is unknown stay apart" pass "chords whose dispatch is unknown stay apart"
@@ -199,10 +199,10 @@ pass "chords whose dispatch is unknown stay apart"
# the script, so dropping an action from the list fails instead of shrinking # the script, so dropping an action from the list fails instead of shrinking
# what gets checked. # what gets checked.
expected_alternatives=( expected_alternatives=(
"Close window" "关闭窗口"
"Calculator" "计算器"
"Toggle scratchpad" "切换便签区"
"Move window to scratchpad" "窗口移入便签区"
) )
eval "$(sed -n '/^alternative_chord_actions()/,/^}/p' "$ROOT/bin/omarchy-menu-keybindings")" eval "$(sed -n '/^alternative_chord_actions()/,/^}/p' "$ROOT/bin/omarchy-menu-keybindings")"