diff --git a/electron/package.json b/electron/package.json index 184615e6..4ace0993 100644 --- a/electron/package.json +++ b/electron/package.json @@ -76,6 +76,13 @@ "**/*" ] }, + { + "from": "build-staging/fn-watcher/${arch}", + "to": "fn-watcher", + "filter": [ + "**/*" + ] + }, { "from": "build-staging/haptics/${arch}", "to": "haptics", diff --git a/electron/scripts/build-fn-watcher.sh b/electron/scripts/build-fn-watcher.sh new file mode 100755 index 00000000..b8fb10b1 --- /dev/null +++ b/electron/scripts/build-fn-watcher.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Compile the macOS fn/Globe key watcher for one arch and stage it where electron-builder's +# extraResources picks it up (build-staging/fn-watcher/). See electron/native/fn-watcher.swift +# for why this exists (libuiohook cannot see keycode 63, so dictation's fn trigger needs a native tap). +set -euo pipefail + +ARCH="${1:?usage: build-fn-watcher.sh }" + +HERE="$(cd "$(dirname "$0")/.." && pwd)" # electron/ +SRC="$HERE/native/fn-watcher.swift" +OUT="$HERE/build-staging/fn-watcher/$ARCH" +TARGET="arm64-apple-macos11" +[[ "$ARCH" == "x64" ]] && TARGET="x86_64-apple-macos11" + +echo "[fn-watcher] building for arch=$ARCH (target $TARGET)" +mkdir -p "$OUT" +swiftc -O -target "$TARGET" -o "$OUT/fn-watcher" "$SRC" +echo "[fn-watcher] staged -> $OUT/fn-watcher" +file "$OUT/fn-watcher" diff --git a/electron/voiceHotkey.js b/electron/voiceHotkey.js index a47a3277..aa7016fb 100644 --- a/electron/voiceHotkey.js +++ b/electron/voiceHotkey.js @@ -58,7 +58,7 @@ function parseCombo(str) { // stay primary on null). The dev compile is async: a first-boot swiftc must never freeze startup. function resolveFnWatcherBinary(cb) { if (process.platform !== 'darwin') { cb(null); return; } - const bundled = path.join(process.resourcesPath || '', 'fn-watcher'); + const bundled = path.join(process.resourcesPath || '', 'fn-watcher', 'fn-watcher'); if (fs.existsSync(bundled)) { cb(bundled); return; } const src = path.join(__dirname, 'native', 'fn-watcher.swift'); if (!fs.existsSync(src)) { cb(null); return; } diff --git a/scripts/build-app.sh b/scripts/build-app.sh index eb58f9f7..8fa41b36 100755 --- a/scripts/build-app.sh +++ b/scripts/build-app.sh @@ -502,6 +502,9 @@ if [[ "$(uname)" == "Darwin" ]]; then echo "Building whisper-server for dictation (arm64 + x64)..." bash scripts/build-whisper.sh arm64 bash scripts/build-whisper.sh x64 + echo "Building fn-watcher for dictation's fn key (arm64 + x64)..." + bash scripts/build-fn-watcher.sh arm64 + bash scripts/build-fn-watcher.sh x64 fi # Node's default ~4 GB heap OOMs while codesign'ing the .app on dual-arch