From 45daeb61ba451ae2adedc4a99f4dd40d9f4666ab Mon Sep 17 00:00:00 2001 From: Natalie Date: Sun, 17 May 2026 18:18:15 -0700 Subject: [PATCH] =?UTF-8?q?feat(@scripts):=20=E2=9C=A8=20add=20voice=20tog?= =?UTF-8?q?gle=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- bin/rclaude | 48 ++++++++++++++++++++++++++++++++++++++++++ hammerspoon/rvoice.lua | 16 ++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/bin/rclaude b/bin/rclaude index cc31bf3..309afa0 100755 --- a/bin/rclaude +++ b/bin/rclaude @@ -1026,6 +1026,53 @@ if [ "${RCLAUDE_LIB_ONLY:-0}" = "1" ]; then return 0 2>/dev/null || exit 0 fi +cmd_voice() { + # `rclaude voice` — toggle / inspect the rvoice push-to-talk binding. + # rvoice itself is a separate script (bin/rvoice) driven by Hammerspoon. + # This subcommand just gates whether the Hammerspoon tap is active by + # writing/removing a sentinel file the lua module checks at load. + _flag=${XDG_STATE_HOME:-$HOME/.local/state}/rclaude/voice-disabled + mkdir -p "$(dirname "$_flag")" 2>/dev/null + _action=${1:-status} + case $_action in + on|enable) + rm -f "$_flag" + _reload_hammerspoon + echo "rvoice: enabled (Right ⌥ = push-to-talk)" ;; + off|disable) + : > "$_flag" + _reload_hammerspoon + echo "rvoice: disabled (delete $_flag or 'rclaude voice on' to re-enable)" ;; + status) + if [ -f "$_flag" ]; then echo "rvoice: disabled" + else echo "rvoice: enabled"; fi + command -v rvoice >/dev/null 2>&1 \ + && echo " rvoice binary: $(command -v rvoice)" \ + || echo " rvoice binary: NOT INSTALLED" ;; + test|target) + command -v rvoice >/dev/null 2>&1 || { echo "rclaude: rvoice not on PATH" >&2; exit 1; } + rvoice target ;; + log) + command -v rvoice >/dev/null 2>&1 && rvoice log ;; + *) + cat </dev/null || true +} + cmd_setup() { # Args: # (none) → install on every host in scan_hosts @@ -1051,6 +1098,7 @@ case ${1:-} in resume) shift; cmd_resume "$@"; exit ;; triage) shift; cmd_triage "$@"; exit ;; setup|install) shift; cmd_setup "$@"; exit ;; + voice) shift; cmd_voice "$@"; exit ;; -v|--version) cmd_version; exit ;; -h|--help|help) cmd_help; exit ;; esac diff --git a/hammerspoon/rvoice.lua b/hammerspoon/rvoice.lua index 106914b..1d74e63 100644 --- a/hammerspoon/rvoice.lua +++ b/hammerspoon/rvoice.lua @@ -33,6 +33,22 @@ end local RVOICE = resolveRvoice() local holding = false +-- rvoice can be toggled off via `rclaude voice off`, which drops a sentinel +-- file. If present at load time, skip starting the eventtap entirely so the +-- Right-⌥ key behaves normally. `rclaude voice on` calls reloadConfig which +-- re-runs this module. +local DISABLE_FLAG = (os.getenv("XDG_STATE_HOME") or (os.getenv("HOME") .. "/.local/state")) + .. "/rclaude/voice-disabled" +local function isDisabled() + local f = io.open(DISABLE_FLAG, "r") + if f then f:close(); return true end + return false +end +if isDisabled() then + hs.alert.show("rvoice: disabled (rclaude voice on to re-enable)") + return {} +end + -- Run rvoice in the background; capture stderr to the system log so -- failures are visible via Hammerspoon's console. local function run(cmd)