Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions bin/omarchy-voxtype-open-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# omarchy:summary=Open Voxtype configuration, or the installer if Voxtype isn't installed yet

set -e

if omarchy-cmd-missing voxtype; then
omarchy-launch-floating-terminal-with-presentation omarchy-voxtype-install
else
omarchy-voxtype-config
fi
4 changes: 3 additions & 1 deletion install/user/first-run/install-voxtype.hook
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

set -e

if omarchy-done ensure voxtype-install-invitation; then
# Upgraded accounts reach this hook through a backfill migration, and Voxtype
# predates the upgrade, so many of them already run it. Invite only who needs it.
if omarchy-cmd-missing voxtype && omarchy-done ensure voxtype-install-invitation; then
omarchy-notification-send -u critical -g  "Install Dictation with Voxtype" \
"Click to install voice dictation for Omarchy." \
--exec "omarchy-launch-floating-terminal-with-presentation omarchy-voxtype-install"
Expand Down
9 changes: 9 additions & 0 deletions migrations/1786719479.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
echo "Invite existing installs to install Voxtype dictation"

# The invitation is installed by first-run, which existing accounts have already
# marked complete, so they would never receive it — the same gap fixed for the
# agent-picker invitation in 1786549201.sh.
#
# Post-update hooks run later in this same update, so the invitation appears
# without waiting for another one. The hook decides whether to notify.
omarchy-hook-install post-update "$OMARCHY_PATH/install/user/first-run/install-voxtype.hook"
2 changes: 1 addition & 1 deletion shell/plugins/bar/indicators/Dictation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ BarIndicator {

onPressed: function() {
if (!root.bar) return
root.bar.run("omarchy-voxtype-config")
root.bar.run("omarchy-voxtype-open-config")
}
}
2 changes: 1 addition & 1 deletion test/shell.d/fixtures/indicator-contract/shell.qml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ ShellRoot {
root.injectBar(dictation)
dictation.triggerPress(Qt.LeftButton)
dictation.triggerPress(Qt.RightButton)
root.assertTrue(root.commandCount("omarchy-voxtype-config") === 2, "Dictation clicks run config command")
root.assertTrue(root.commandCount("omarchy-voxtype-open-config") === 2, "Dictation clicks open config, checking voxtype install state first")
root.assertTrue(root.commandCount("omarchy-voxtype-model") === 0, "Dictation clicks do not run model command")
}

Expand Down
25 changes: 22 additions & 3 deletions test/shell.d/voxtype-invitation-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,30 @@ echo "systemd-run:$*" >>"$TEST_LOG"
EOF
chmod +x "$test_bin/systemd-run"

# Stub the presence check rather than the PATH: the hook needs the real
# coreutils, so a voxtype on the host (e.g. this dev machine) would otherwise
# decide the test.
cat >"$test_bin/omarchy-cmd-missing" <<'EOF'
#!/bin/bash
[[ -n $TEST_VOXTYPE_MISSING ]]
EOF
chmod +x "$test_bin/omarchy-cmd-missing"

run_invitation_hook() {
local voxtype_missing=$1

cp "$ROOT/install/user/first-run/install-voxtype.hook" "$hook_path"
HOME="$test_home" PATH="$test_bin:$ROOT/bin:$PATH" TEST_LOG="$log_file" bash "$hook_path"
HOME="$test_home" PATH="$test_bin:$ROOT/bin:$PATH" TEST_LOG="$log_file" \
TEST_VOXTYPE_MISSING="$voxtype_missing" bash "$hook_path"
}

run_invitation_hook
run_invitation_hook ""

[[ -s $log_file ]] && fail "Voxtype invitation stays quiet when voxtype is installed" "$(cat "$log_file")"
[[ -f $test_home/.local/state/omarchy/done/voxtype-install-invitation ]] &&
fail "Voxtype invitation keeps its one-time marker unspent while voxtype is installed"

run_invitation_hook 1

[[ -f $test_home/.local/state/omarchy/done/voxtype-install-invitation ]] || fail "Voxtype invitation records completion"
[[ -f $hook_path ]] || fail "Voxtype invitation keeps its hook installed"
Expand All @@ -47,7 +65,8 @@ grep -qx 'exec:omarchy-launch-floating-terminal-with-presentation omarchy-voxtyp
fail "Voxtype invitation attaches the installer to the notification"
grep -q '^systemd-run:' "$log_file" && fail "Voxtype invitation needs no unit to hold an unanswered toast"

HOME="$test_home" PATH="$test_bin:$ROOT/bin:$PATH" TEST_LOG="$log_file" bash "$hook_path"
HOME="$test_home" PATH="$test_bin:$ROOT/bin:$PATH" TEST_LOG="$log_file" \
TEST_VOXTYPE_MISSING=1 bash "$hook_path"

[[ -f $hook_path ]] || fail "completed Voxtype invitation keeps its hook installed"
[[ $(grep -c '^notification$' "$log_file") -eq 1 ]] || fail "completed Voxtype invitation hook does not notify again"
Expand Down
50 changes: 50 additions & 0 deletions test/shell.d/voxtype-open-config-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

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

test_bin=$(mktemp -d)
log_file=$(mktemp)

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

cat >"$test_bin/omarchy-launch-floating-terminal-with-presentation" <<'EOF'
#!/bin/bash
echo "install:$*" >>"$TEST_LOG"
EOF
chmod +x "$test_bin/omarchy-launch-floating-terminal-with-presentation"

cat >"$test_bin/omarchy-voxtype-config" <<'EOF'
#!/bin/bash
echo "config" >>"$TEST_LOG"
EOF
chmod +x "$test_bin/omarchy-voxtype-config"

run_open_config() {
local path=$1
PATH="$path" TEST_LOG="$log_file" /bin/bash "$ROOT/bin/omarchy-voxtype-open-config"
}

# voxtype missing: use a PATH scoped to the stubs so a real voxtype
# elsewhere on the host (e.g. this dev machine) can't leak in.
run_open_config "$test_bin:$ROOT/bin"
[[ $(cat "$log_file") == "install:omarchy-voxtype-install" ]] ||
fail "opens the installer when voxtype is missing" "$(cat "$log_file")"

: >"$log_file"

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

# voxtype present: only config runs, never the installer
run_open_config "$test_bin:$ROOT/bin"
[[ $(cat "$log_file") == "config" ]] ||
fail "opens config when voxtype is installed" "$(cat "$log_file")"

pass "Voxtype open-config dispatches to the installer or config based on install state, never both"