From 02d28d273a1b0f45d9beb19243b2ee6caf5e7a7d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 8 Oct 2026 21:19:48 +0200 Subject: [PATCH] Fix Superwhisper setup with existing Right Alt shortcut --- bin/omarchy-install-dictation-superwhisper | 10 ++++++++++ test/shell.d/dictation-test.sh | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/bin/omarchy-install-dictation-superwhisper b/bin/omarchy-install-dictation-superwhisper index f2835e55..841f0c4e 100755 --- a/bin/omarchy-install-dictation-superwhisper +++ b/bin/omarchy-install-dictation-superwhisper @@ -7,6 +7,16 @@ set -e omarchy-pkg-add superwhisper-bin bash /usr/share/superwhisper/setup-user +# Existing profiles may still use Right Alt, which conflicts with Omarchy. +# Keep a recording shortcut active while moving away from that binding. +shortcuts=$(superwhisper shortcuts show) +if [[ $(jq -r '.shortcuts.hold' <<< "$shortcuts") == "RightAlt" ]]; then + if [[ -z $(jq -r '.shortcuts.toggle' <<< "$shortcuts") ]]; then + superwhisper shortcuts set hold "RightSuper" >/dev/null + else + superwhisper shortcuts set hold none >/dev/null + fi +fi # Superwhisper requires a native recording shortcut; keep it separate from # Omarchy's push-to-talk keys. superwhisper shortcuts set toggle "Alt+Space" >/dev/null diff --git a/test/shell.d/dictation-test.sh b/test/shell.d/dictation-test.sh index 5137653c..b1de2b63 100644 --- a/test/shell.d/dictation-test.sh +++ b/test/shell.d/dictation-test.sh @@ -33,6 +33,17 @@ for backend in voxtype superwhisper; do printf '%s %s\n' "${0##*/}" "$*" >> "$DICTATION_LOG" if [[ $1 == "status" ]]; then echo "${VOXTYPE_STATUS:-idle}"; exit 0; fi if [[ -n ${FAIL_SETUP_STEP:-} && $* == "$FAIL_SETUP_STEP" ]]; then exit 7; fi +if [[ ${0##*/} == "superwhisper" && $1 == "shortcuts" && ${DICTATION_EXIT:-0} == 0 ]]; then + if [[ $2 == "show" ]]; then + cat "$SHORTCUT_STATE" + elif [[ $2 == "set" ]]; then + chord=$4 + [[ $chord != "none" ]] || chord="" + updated=$(jq --arg action "$3" --arg chord "$chord" '.shortcuts[$action] = $chord' "$SHORTCUT_STATE") + jq -e '.shortcuts | .hold != "RightAlt" and (.hold != "" or .toggle != "")' <<< "$updated" >/dev/null || exit 1 + printf '%s\n' "$updated" > "$SHORTCUT_STATE" + fi +fi exit "${DICTATION_EXIT:-0}" SH done @@ -126,12 +137,19 @@ if omarchy-dictation start 2> "$test_tmp/error"; then fail "invalid backend must pass "external adapters follow the same protocol and errors propagate" printf '%s\n' voxtype > "$config" +export SHORTCUT_STATE="$test_tmp/shortcuts.json" +printf '%s\n' '{"shortcuts":{"hold":"RightAlt","toggle":"","cancel":"Escape"}}' > "$SHORTCUT_STATE" if SETUP_EXIT=1 omarchy-install-dictation-superwhisper > "$test_tmp/output" 2>&1; then fail "failed installation must fail"; fi [[ $(cat "$config") == "voxtype" ]] || fail "failed setup must preserve selection" if DICTATION_EXIT=7 omarchy-install-dictation-superwhisper > "$test_tmp/output" 2>&1; then fail "failed shortcut setup must fail"; fi [[ $(cat "$config") == "voxtype" ]] || fail "failed shortcuts must preserve selection" omarchy-install-dictation-superwhisper [[ $(omarchy-default-dictation) == "superwhisper" ]] || fail "installer selects Superwhisper" +jq -e '.shortcuts | .hold == "" and .toggle == "Alt+Space"' "$SHORTCUT_STATE" >/dev/null || fail "installer repairs conflicting hold-only profiles" +printf '%s\n' '{"shortcuts":{"hold":"RightAlt","toggle":"RightSuper","cancel":"Escape"}}' > "$SHORTCUT_STATE" +omarchy-install-dictation-superwhisper +jq -e '.shortcuts | .hold == "" and .toggle == "Alt+Space"' "$SHORTCUT_STATE" >/dev/null || fail "installer repairs conflicting profiles with an existing toggle" +omarchy-install-dictation-superwhisper pass "Superwhisper installer owns setup and saves selection only after success" DICTATION_INSTALLED=superwhisper