-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·65 lines (49 loc) · 2.08 KB
/
build.sh
File metadata and controls
executable file
·65 lines (49 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
set -euo pipefail
if ! command -v osacompile >/dev/null || ! command -v defaults >/dev/null || ! command -v plutil >/dev/null; then
echo "Could not find osacompile, defaults and/or plutil commands!"
echo "This script will only work on macOS hosts."
exit 1
fi
TARGET="Switch Capture Tagger.app"
SOURCE="Switch Capture Tagger.js"
# We need to resolve the current directory as an absolute path for later use
SCRIPTDIR="$(cd "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"
if [[ -d "$SCRIPTDIR/$TARGET" ]]; then
echo "Removing existing build..."
rm -rf "${SCRIPTDIR:?}/$TARGET"
fi
echo "Compiling script to app..."
osacompile -l JavaScript \
-o "$SCRIPTDIR/$TARGET" \
"$SCRIPTDIR/$SOURCE"
echo "Writing app metadata..."
PLIST="$SCRIPTDIR/$TARGET/Contents/Info.plist"
function deleteInfo {
defaults delete "$PLIST" "$1"
}
function writeInfo {
defaults write "$PLIST" "$1" "$2"
}
# We *don't* use Apple Music, Calendars, Camera, Contacts, HomeKit,
# Microphone, Photo Library API, Reminders, Siri or Administrator access
deleteInfo NSAppleMusicUsageDescription
deleteInfo NSCalendarsUsageDescription
deleteInfo NSCameraUsageDescription
deleteInfo NSContactsUsageDescription
deleteInfo NSHomeKitUsageDescription
deleteInfo NSMicrophoneUsageDescription
deleteInfo NSPhotoLibraryUsageDescription
deleteInfo NSRemindersUsageDescription
deleteInfo NSSiriUsageDescription
deleteInfo NSSystemAdministrationUsageDescription
# Update relevant metadata
writeInfo NSAppleEventsUsageDescription "Access to control Photos is necessary so Switch Capture Tagger can find Switch captures, read their names, and update their date, time and keywords"
writeInfo CFBundleIdentifier "net.jessicastokes.switch-capture-tagger"
writeInfo CFBundleShortVersionString "0.1.0"
writeInfo NSHumanReadableCopyright "Copyright © 2020 Jessica Stokes"
# For whatever reason, defaults really likes to convert to binary form,
# for readability we convert back to xml format like most other apps use
plutil -convert xml1 "$PLIST"
# TODO: Icon?
echo "Done! The app can be found at $SCRIPTDIR/$TARGET"