mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
Rework the GPUI desktop UI toward a native Mac feel: real NSVisualEffectView sidebar and HUD glass, unified toolbar, hairlines instead of boxed panels, macOS 24 pt controls, accent switches, no hover or pointer cursor outside menus, focus rings, inactive-window dimming, tabular figures, a speaker-margin transcript, concentric meeting capsules with Core Animation entrance and exit, and straight-alpha SF Symbols. Adds screen-rect frame recording and a controls choreography for motion evidence.
86 lines
2.7 KiB
Shell
Executable file
86 lines
2.7 KiB
Shell
Executable file
#!/bin/sh
|
|
set -eu
|
|
|
|
if [ "$#" -lt 2 ]; then
|
|
echo "usage: $0 OUTPUT TARGET [PREVIEW OPTIONS...]" >&2
|
|
exit 2
|
|
fi
|
|
|
|
output=$1
|
|
shift
|
|
target=$1
|
|
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
|
|
cd "$root"
|
|
if [ -n "${HEX_PREVIEW_BINARY:-}" ]; then
|
|
binary=$HEX_PREVIEW_BINARY
|
|
else
|
|
binary=$root/target/release/voice-control
|
|
fi
|
|
if [ -z "${HEX_PREVIEW_BINARY:-}" ] && [ "${HEX_PREVIEW_SKIP_BUILD:-0}" != "1" ]; then
|
|
CMAKE=${CMAKE:-/opt/homebrew/lib/python3.10/site-packages/cmake/data/bin/cmake} \
|
|
cargo build --release --bin voice-control
|
|
elif [ ! -x "$binary" ]; then
|
|
echo "preview binary does not exist: $binary" >&2
|
|
exit 1
|
|
fi
|
|
|
|
"$binary" preview "$@" &
|
|
pid=$!
|
|
cleanup() {
|
|
kill "$pid" 2>/dev/null || true
|
|
wait "$pid" 2>/dev/null || true
|
|
}
|
|
trap cleanup EXIT INT TERM
|
|
|
|
window_id=$(swift - "$pid" "$target" <<'SWIFT'
|
|
import CoreGraphics
|
|
import Foundation
|
|
|
|
let pid = Int(CommandLine.arguments[1])!
|
|
let target = CommandLine.arguments[2]
|
|
for _ in 0..<200 {
|
|
let windows = CGWindowListCopyWindowInfo(
|
|
[.optionOnScreenOnly, .excludeDesktopElements],
|
|
kCGNullWindowID
|
|
) as! [[String: Any]]
|
|
let candidates = windows.filter { window in
|
|
guard (window[kCGWindowOwnerPID as String] as? Int) == pid else {
|
|
return false
|
|
}
|
|
if target == "dictation-hud" || target == "meeting-offer" || target == "meeting-capsule" {
|
|
return true
|
|
}
|
|
let title = window[kCGWindowName as String] as? String
|
|
let bounds = window[kCGWindowBounds as String] as? [String: CGFloat]
|
|
return (title == nil || title == "" || title == "Hex")
|
|
&& (bounds?["Width"] ?? 0) >= 800
|
|
&& (bounds?["Height"] ?? 0) >= 400
|
|
}
|
|
if let window = candidates.max(by: {
|
|
let lhs = $0[kCGWindowBounds as String] as! [String: CGFloat]
|
|
let rhs = $1[kCGWindowBounds as String] as! [String: CGFloat]
|
|
return lhs["Width"]! * lhs["Height"]! < rhs["Width"]! * rhs["Height"]!
|
|
}) {
|
|
print(window[kCGWindowNumber as String] as! Int)
|
|
exit(0)
|
|
}
|
|
Thread.sleep(forTimeInterval: 0.05)
|
|
}
|
|
exit(1)
|
|
SWIFT
|
|
)
|
|
|
|
mkdir -p "$(dirname -- "$output")"
|
|
# Let entrance animations (capsules slide in over 0.32 s) settle first.
|
|
sleep "${HEX_PREVIEW_SETTLE_SECONDS:-0.6}"
|
|
if ! screencapture -x -l "$window_id" "$output" 2>/dev/null; then
|
|
cua_bin=$(command -v cua-driver 2>/dev/null || printf '%s/.local/bin/cua-driver' "$HOME")
|
|
if [ -x "$cua_bin" ]; then
|
|
abs_out=$(CDPATH= cd -- "$(dirname -- "$output")" && pwd)/$(basename -- "$output")
|
|
"$cua_bin" call get_window_state "{\"pid\":$pid,\"window_id\":$window_id,\"include_accessibility_tree\":false,\"max_image_dimension\":0,\"screenshot_out_file\":\"$abs_out\"}" >/dev/null
|
|
else
|
|
screencapture -x -l "$window_id" "$output"
|
|
fi
|
|
fi
|
|
echo "$output"
|