#!/bin/sh

project_root="$(dirname $0)/../"

killall CutBox
rm -rf /Applications/CutBox.app
cp -R "${project_root}/CutBox/build/CutBox.app" /Applications/

open "x-apple.systempreferences:com.apple.preference.security?Privacy"

cat <<EOF
Add CutBox to Security & Privacy > Privacy > 'Accessibility'
(You must remove it if it's already there, and re-add it, for any new version.)

Please do this before continuing...

Press [y] to continue (any other key will abort)
EOF

while :
do
  read -rn 1 KEY <&1

  if [[ $KEY = "y" ]]; then
    break
  else
    echo ""
    echo "quitting..."
    exit 1
  fi
done

open -a /Applications/CutBox.app
