#!/bin/bash
DIR="$(cd "$(dirname "$0")" && pwd)"
RESOURCES="$DIR/../Resources"
export LOG_DIR="${HOME}/Library/Logs/无障碍助手"
mkdir -p "$LOG_DIR"

# Run start.sh; keep a small log of launcher itself
"$RESOURCES/start.sh" >>"$LOG_DIR/launcher.log" 2>&1
STATUS=$?

# If failed, show a VoiceOver-friendly dialog
if [[ $STATUS -ne 0 ]]; then
  osascript <<'APPLESCRIPT' 2>/dev/null || true
display dialog "无障碍助手启动失败。请确认已安装 WorkBuddy，并查看日志：~/Library/Logs/无障碍助手/" buttons {"好"} default button 1 with title "无障碍助手" with icon stop
APPLESCRIPT
fi
exit $STATUS
