#!/bin/bash source "$(dirname "${BASH_SOURCE[0]}")/base-test.sh" require_command lua require_command xkbcli tmpdir=$(mktemp -d) && [[ -n $tmpdir && -d $tmpdir ]] || fail "the test gets a temporary directory to stub Hyprland in" trap 'rm -rf "$tmpdir"' EXIT home="$tmpdir/home" stub_bin="$tmpdir/bin" mkdir -p "$home/.config" "$stub_bin" cp -r "$ROOT/config/hypr" "$home/.config/hypr" # The menu reads binds from Hyprland, which is not running here, so stand in for # it. A Lua bind reports dispatcher __lua and no arg, and the menu recovers both # from the Lua source; an exec bind carries its own command. Both shapes matter: # what two chords dispatch is what decides whether they share a row. lua_bind() { printf 'bind\n\tmodmask: %s\n\tsubmap: \n\tkey: %s\n\tkeycode: 0\n\tcatchall: false\n\tdescription: %s\n\tdispatcher: __lua\n\targ: \n' "$1" "$2" "$3" } exec_bind() { printf 'bind\n\tmodmask: %s\n\tsubmap: \n\tkey: %s\n\tkeycode: 0\n\tcatchall: false\n\tdescription: %s\n\tdispatcher: exec\n\targ: %s\n' "$1" "$2" "$3" "$4" } stub_hyprctl() { { echo '#!/bin/bash' echo 'case "$1" in' echo ' binds) cat <<'"'"'BINDS'"'"'' cat echo 'BINDS' echo ' ;;' echo ' devices) echo "active keymap: English (US)" ;;' echo 'esac' } >"$stub_bin/hyprctl" chmod +x "$stub_bin/hyprctl" } keybindings() { env -i PATH="$stub_bin:$ROOT/bin:$PATH" HOME="$home" \ XDG_CACHE_HOME="$tmpdir/cache" OMARCHY_PATH="$ROOT" \ bash "$ROOT/bin/omarchy-menu-keybindings" --print } # Closing a window and toggling the scratchpad are two of the actions 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. stub_hyprctl <= 2 )) || fail "every action named as having an alternative is bound twice" "$action" done pass "every action named as having an alternative is bound twice"