Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions bin/omarchy-hw-x86-64-v3
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# omarchy:summary=Detect whether the CPU supports the x86-64-v3 baseline (AVX2, FMA, BMI1, BMI2, F16C, MOVBE).

[[ $(uname -m) == "x86_64" ]] || exit 0

cpuinfo=${OMARCHY_CPUINFO_PATH:-/proc/cpuinfo}
flags=" $(grep -m1 "^flags" "$cpuinfo" 2>/dev/null | cut -d: -f2) "

for flag in avx2 fma bmi1 bmi2 f16c movbe; do
[[ $flags == *" $flag "* ]] || exit 1
done
56 changes: 43 additions & 13 deletions bin/omarchy-voxtype-install
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,54 @@
# omarchy:summary=Install and configure Voxtype dictation
# omarchy:requires-sudo=true

set -e

# Install voxtype and configure it for use.

if gum confirm "Install Voxtype + AI model (~150MB) to enable dictation?"; then
omarchy-pkg-add wtype voxtype-bin
omarchy-pkg-add wtype || exit 1

# Setup voxtype
mkdir -p ~/.config/voxtype
cp "$OMARCHY_PATH/default/voxtype/config.toml" ~/.config/voxtype/
voxtype_pkg=voxtype-bin
if ! omarchy-hw-x86-64-v3; then
gum style --foreground 3 \
"Your CPU is missing instructions (AVX2/x86-64-v3) that the prebuilt Voxtype binary requires."

voxtype setup --download --no-post-install
if omarchy-hw-vulkan; then
voxtype setup gpu --enable || true
if gum confirm "Build Voxtype from source instead? This can take 20+ minutes and may result in noticeably slower dictation on this CPU."; then
if ! omarchy-pkg-aur-accessible; then
gum style --foreground 1 "The AUR is unreachable right now, so Voxtype can't be built from source. Try again later."
exit 1
fi
voxtype_pkg=voxtype
else
echo "Skipping Voxtype install."
exit 0
fi
fi
voxtype setup systemd

hyprctl reload >/dev/null
omarchy-restart-shell
omarchy-notification-send -g  "Voxtype Dictation Ready" "Hold F9 to dictate (or toggle with Super + Ctrl + X)." -t 10000
if [[ $voxtype_pkg == voxtype-bin ]]; then
omarchy-pkg-add voxtype-bin || exit 1
else
omarchy-pkg-aur-add voxtype || exit 1
fi

# Setup voxtype
install_voxtype() {
mkdir -p ~/.config/voxtype
cp "$OMARCHY_PATH/default/voxtype/config.toml" ~/.config/voxtype/ || return 1

voxtype setup --download --no-post-install || return 1
if omarchy-hw-vulkan; then
voxtype setup gpu --enable || true
fi
voxtype setup systemd || return 1

hyprctl reload >/dev/null
omarchy-restart-shell
}

if install_voxtype; then
omarchy-notification-send -g "Voxtype Dictation Ready" "Hold F9 to dictate (or toggle with Super + Ctrl + X)." -t 10000
else
gum style --foreground 1 "Voxtype setup failed. Rolling back the install."
omarchy-voxtype-remove
exit 1
fi
fi
6 changes: 4 additions & 2 deletions bin/omarchy-voxtype-remove
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ if omarchy-cmd-present voxtype; then
systemctl --user disable --now voxtype.service 2>/dev/null || true
systemctl --user daemon-reload

# Remove packages and configs
omarchy-pkg-drop voxtype-bin
# Remove packages and configs. voxtype-bin is the prebuilt binary; voxtype
# is the cargo-built fallback offered on CPUs without the AVX2/x86-64-v3
# instructions voxtype-bin requires. Only one of the two is ever installed.
omarchy-pkg-drop voxtype-bin voxtype
rm -rf ~/.config/voxtype
rm -rf ~/.local/share/voxtype
hyprctl reload >/dev/null
Expand Down
2 changes: 2 additions & 0 deletions manual/11-text-extraction-dictation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ This is very helpful for grabbing addresses out of image footers or phone number

Omarchy offers AI dictation via [Voxtype](https://voxtype.io/). You install it via _Install > AI > Dictation_ through the Omarchy menu. By default, it'll load a base English model that takes up 150MB. But you can tweak which model you'd like to use by running `voxtype setup model` in the terminal. And you can tweak all the settings via `~/.config/voxtype/config.toml`.

The prebuilt Voxtype binary requires a CPU with the x86-64-v3 instruction baseline (AVX2, FMA, BMI1/2, F16C, MOVBE — Haswell-era or newer, roughly 2013+). On older CPUs, the installer offers to build Voxtype from source via the AUR instead; this takes 20+ minutes and may run noticeably slower.

Once installed, you dictate by holding down `F9` or by toggling with `Super + Ctrl + X`, and the dictated text will appear in the focused input area.
46 changes: 46 additions & 0 deletions test/shell.d/hw-x86-64-v3-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

tmp_dir=$(mktemp -d)
trap 'rm -rf "$tmp_dir"' EXIT

write_cpuinfo_flags() {
printf 'flags\t\t: %s\n' "$1" >"$tmp_dir/cpuinfo"
}

hw_x86_64_v3() {
OMARCHY_CPUINFO_PATH="$tmp_dir/cpuinfo" "$ROOT/bin/omarchy-hw-x86-64-v3"
}

assert_detects() {
local description="$1"

hw_x86_64_v3 || fail "$description"
pass "$description"
}

assert_rejects() {
local description="$1"

if hw_x86_64_v3; then
fail "$description"
fi
pass "$description"
}

# Ivy Bridge (e.g. i7-3520M): has AVX but not AVX2/BMI/FMA.
write_cpuinfo_flags "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc aperfmperf tsc_known_freq pni pclmulqdq est ssse3 fma cx16 sse4_1 sse4_2 popcnt aes xsave avx f16c rdrand hypervisor lahf_lm"
assert_rejects "Ivy Bridge without AVX2/BMI1/BMI2 does not satisfy x86-64-v3"

# Haswell and newer: full x86-64-v3 baseline.
write_cpuinfo_flags "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm abm avx2 bmi1 bmi2"
assert_detects "Haswell with the full x86-64-v3 baseline satisfies it"

write_cpuinfo_flags "fpu vme de pse tsc msr avx avx2"
assert_rejects "AVX2 alone without FMA/BMI1/BMI2/F16C/MOVBE does not satisfy x86-64-v3"

: >"$tmp_dir/cpuinfo"
assert_rejects "empty cpuinfo does not satisfy x86-64-v3"
126 changes: 126 additions & 0 deletions test/shell.d/voxtype-install-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!/bin/bash

source "$(dirname "$0")/base-test.sh"

test_home=$(mktemp -d)
test_bin=$(mktemp -d)
test_omarchy_path=$(mktemp -d)
log_file=$(mktemp)
confirm_queue=$(mktemp)

cleanup() {
rm -rf "$test_home" "$test_bin" "$test_omarchy_path"
rm -f "$log_file" "$confirm_queue"
}
trap cleanup EXIT

mkdir -p "$test_omarchy_path/default/voxtype"
echo "# stub config" >"$test_omarchy_path/default/voxtype/config.toml"

# gum answers confirm prompts in order from confirm_queue (one "yes"/"no" per
# line), and no-ops for every other subcommand (style, etc.).
cat >"$test_bin/gum" <<'EOF'
#!/bin/bash
if [[ $1 == "confirm" ]]; then
echo "confirm:$2" >>"$TEST_LOG"
answer=$(head -n1 "$CONFIRM_QUEUE")
sed -i '1d' "$CONFIRM_QUEUE"
[[ $answer == "yes" ]]
exit $?
fi
exit 0
EOF
chmod +x "$test_bin/gum"

for cmd in omarchy-pkg-add omarchy-pkg-aur-add omarchy-restart-shell omarchy-notification-send omarchy-voxtype-remove; do
cat >"$test_bin/$cmd" <<EOF
#!/bin/bash
echo "$cmd:\$*" >>"\$TEST_LOG"
EOF
chmod +x "$test_bin/$cmd"
done

cat >"$test_bin/hyprctl" <<'EOF'
#!/bin/bash
exit 0
EOF
chmod +x "$test_bin/hyprctl"

cat >"$test_bin/omarchy-hw-vulkan" <<'EOF'
#!/bin/bash
exit 1
EOF
chmod +x "$test_bin/omarchy-hw-vulkan"

cat >"$test_bin/omarchy-pkg-aur-accessible" <<'EOF'
#!/bin/bash
exit "${AUR_ACCESSIBLE:-0}"
EOF
chmod +x "$test_bin/omarchy-pkg-aur-accessible"

write_hw_x86_64_v3() {
cat >"$test_bin/omarchy-hw-x86-64-v3" <<EOF
#!/bin/bash
exit $1
EOF
chmod +x "$test_bin/omarchy-hw-x86-64-v3"
}

write_voxtype_stub() {
local setup_exit="${1:-0}"
cat >"$test_bin/voxtype" <<EOF
#!/bin/bash
echo "voxtype:\$*" >>"\$TEST_LOG"
if [[ \$1 == "setup" && \$2 == "--download" ]]; then
exit $setup_exit
fi
exit 0
EOF
chmod +x "$test_bin/voxtype"
}

run_install() {
local answers="$1"
: >"$log_file"
printf '%s\n' $answers >"$confirm_queue"
HOME="$test_home" OMARCHY_PATH="$test_omarchy_path" PATH="$test_bin:$ROOT/bin:$PATH" \
TEST_LOG="$log_file" CONFIRM_QUEUE="$confirm_queue" AUR_ACCESSIBLE="${2:-0}" \
bash "$ROOT/bin/omarchy-voxtype-install"
}

# A CPU with the x86-64-v3 baseline installs the prebuilt binary as before.
write_hw_x86_64_v3 0
write_voxtype_stub 0
run_install "yes"
grep -qx 'omarchy-pkg-add:voxtype-bin' "$log_file" || fail "v3-capable CPU installs voxtype-bin"
grep -q '^omarchy-notification-send:' "$log_file" || fail "v3-capable CPU install sends the ready notification"
grep -q '^omarchy-pkg-aur-add:' "$log_file" && fail "v3-capable CPU install does not touch the AUR"

# A CPU missing the baseline, with the user declining the source build,
# installs nothing.
write_hw_x86_64_v3 1
run_install "yes no"
grep -q '^omarchy-pkg-add:voxtype-bin' "$log_file" && fail "declining the source build does not install the prebuilt binary"
grep -q '^omarchy-pkg-aur-add:' "$log_file" && fail "declining the source build does not touch the AUR"

# A CPU missing the baseline, with the user accepting the source build,
# installs the AUR voxtype package instead of voxtype-bin.
write_hw_x86_64_v3 1
write_voxtype_stub 0
run_install "yes yes" 0
grep -qx 'omarchy-pkg-aur-add:voxtype' "$log_file" || fail "accepting the source build installs voxtype via the AUR"
grep -q '^omarchy-pkg-add:voxtype-bin' "$log_file" && fail "accepting the source build does not install voxtype-bin"

# If the AUR is unreachable, the source-build offer fails cleanly.
write_hw_x86_64_v3 1
run_install "yes yes" 1
grep -q '^omarchy-pkg-aur-add:' "$log_file" && fail "an unreachable AUR does not attempt the source install"

# A failure partway through setup rolls back via omarchy-voxtype-remove
# instead of leaving a half-installed package behind.
write_hw_x86_64_v3 0
write_voxtype_stub 1
run_install "yes"
grep -q '^omarchy-voxtype-remove:' "$log_file" || fail "a failed setup step triggers a rollback"

pass "Voxtype install gates on CPU capability and rolls back on failure"