-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·54 lines (47 loc) · 1.76 KB
/
build.sh
File metadata and controls
executable file
·54 lines (47 loc) · 1.76 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
#!/bin/bash
# Build LidAwake, wrap it in a .app bundle, and install to /Applications.
set -euo pipefail
cd "$(dirname "$0")"
APP="LidAwake.app"
CONTENTS="$APP/Contents"
echo "Compiling LidAwake.swift…"
swiftc LidAwake.swift -o LidAwake -framework Cocoa -framework IOKit -framework CoreGraphics
echo "Building $APP bundle…"
rm -rf "$APP"
mkdir -p "$CONTENTS/MacOS"
cp LidAwake "$CONTENTS/MacOS/LidAwake"
cat > "$CONTENTS/Info.plist" <<'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key> <string>LidAwake</string>
<key>CFBundleExecutable</key> <string>LidAwake</string>
<key>CFBundleIdentifier</key> <string>local.lidawake</string>
<key>CFBundlePackageType</key> <string>APPL</string>
<key>CFBundleShortVersionString</key> <string>1.1</string>
<key>CFBundleIconFile</key> <string>AppIcon</string>
<key>LSMinimumSystemVersion</key> <string>12.0</string>
<key>LSUIElement</key> <true/>
<key>NSAppleEventsUsageDescription</key>
<string>LidAwake uses System Events to manage its Login Items entry.</string>
</dict>
</plist>
PLIST
if [ -f AppIcon.icns ]; then
mkdir -p "$CONTENTS/Resources"
cp AppIcon.icns "$CONTENTS/Resources/AppIcon.icns"
fi
echo "Built $APP"
# Install to /Applications, asking before clobbering an existing copy.
DEST="/Applications/$APP"
if [ -e "$DEST" ]; then
read -r -p "$DEST already exists. Overwrite? [y/N] " reply
case "$reply" in
[yY]*) ;;
*) echo "Skipped install. Run ./$APP/Contents/MacOS/LidAwake to test locally."; exit 0 ;;
esac
fi
rm -rf "$DEST"
cp -R "$APP" "$DEST"
echo "Installed to $DEST"