#!/bin/bash
# SilverBullet — Notes-like system app (standalone window, not a browser tab)
URL="https://silverbullet.hacktivism.ch/"
USER_DATA="${HOME}/Library/Application Support/SilverBullet-BraveProfile"
mkdir -p "$USER_DATA"

BRAVE="/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
CHROME="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"

# Dedicated Chromium profile so this feels like its own app (Dock, cookies, no tab chrome)
if [[ -x "$BRAVE" ]]; then
  exec "$BRAVE" \
    --user-data-dir="$USER_DATA" \
    --class=SilverBullet \
    --app="$URL" \
    --name=SilverBullet
elif [[ -x "$CHROME" ]]; then
  exec "$CHROME" \
    --user-data-dir="$USER_DATA" \
    --class=SilverBullet \
    --app="$URL" \
    --name=SilverBullet
else
  # last resort: Safari has no --app; open dedicated window via osascript
  exec osascript <<'OSA'
tell application "Safari"
  activate
  make new document with properties {URL:"https://silverbullet.hacktivism.ch/"}
end tell
OSA
fi
