-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_app.sh
More file actions
executable file
·126 lines (109 loc) · 4.63 KB
/
build_app.sh
File metadata and controls
executable file
·126 lines (109 loc) · 4.63 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
set -e
cd "$(dirname "$0")"
APP_NAME="SystemTrayTerminal"
BUNDLE="${APP_NAME}.app"
ICON_SRC="icon.png"
BUNDLE_ID="com.l3v0.systemtrayterminal"
# ─── Read version from source of truth ───
VERSION="$(sed -nE 's/^let kAppVersion = "([^"]+)".*/\1/p' systemtrayterminal.swift | head -n1)"
[ -n "$VERSION" ] || { echo "ERROR: kAppVersion not found in systemtrayterminal.swift"; exit 1; }
echo "=== Building ${APP_NAME}.app ==="
# ─── Step 1: Create .icns from PNG ───
echo "[1/4] Creating app icon..."
ICONSET="${APP_NAME}.iconset"
rm -rf "$ICONSET"
mkdir -p "$ICONSET"
# Generate all required icon sizes
sips -z 16 16 "$ICON_SRC" --out "${ICONSET}/icon_16x16.png" > /dev/null 2>&1
sips -z 32 32 "$ICON_SRC" --out "${ICONSET}/icon_16x16@2x.png" > /dev/null 2>&1
sips -z 32 32 "$ICON_SRC" --out "${ICONSET}/icon_32x32.png" > /dev/null 2>&1
sips -z 64 64 "$ICON_SRC" --out "${ICONSET}/icon_32x32@2x.png" > /dev/null 2>&1
sips -z 128 128 "$ICON_SRC" --out "${ICONSET}/icon_128x128.png" > /dev/null 2>&1
sips -z 256 256 "$ICON_SRC" --out "${ICONSET}/icon_128x128@2x.png" > /dev/null 2>&1
sips -z 256 256 "$ICON_SRC" --out "${ICONSET}/icon_256x256.png" > /dev/null 2>&1
sips -z 512 512 "$ICON_SRC" --out "${ICONSET}/icon_256x256@2x.png" > /dev/null 2>&1
sips -z 512 512 "$ICON_SRC" --out "${ICONSET}/icon_512x512.png" > /dev/null 2>&1
sips -z 1024 1024 "$ICON_SRC" --out "${ICONSET}/icon_512x512@2x.png" > /dev/null 2>&1
iconutil -c icns "$ICONSET" -o AppIcon.icns
rm -rf "$ICONSET"
echo " AppIcon.icns created"
# ─── Step 2: Compile binary ───
echo "[2/4] Compiling binary..."
swiftc -O systemtrayterminal.swift -o "${APP_NAME}_bin" \
-framework Cocoa -framework Carbon -framework AVKit \
-Xlinker -sectcreate -Xlinker __FONTS -Xlinker __jbmono -Xlinker _JetBrainsMono-LightItalic-terminal.ttf \
-Xlinker -sectcreate -Xlinker __FONTS -Xlinker __monocraft -Xlinker _Monocraft-terminal.ttf \
-Xlinker -sectcreate -Xlinker __DATA -Xlinker __readme -Xlinker README.md \
-Xlinker -sectcreate -Xlinker __DATA -Xlinker __commands -Xlinker COMMANDS.md \
-Xlinker -sectcreate -Xlinker __DATA -Xlinker __changelog -Xlinker CHANGELOG.md
echo " Binary compiled"
# ─── Step 3: Assemble .app bundle ───
echo "[3/4] Assembling ${BUNDLE}..."
rm -rf "$BUNDLE"
mkdir -p "${BUNDLE}/Contents/MacOS"
mkdir -p "${BUNDLE}/Contents/Resources"
# Binary
mv "${APP_NAME}_bin" "${BUNDLE}/Contents/MacOS/${APP_NAME}"
# Fonts (loaded relative to binary)
cp _FiraCode-Regular-terminal.ttf "${BUNDLE}/Contents/MacOS/"
cp _FiraCode-Bold-terminal.ttf "${BUNDLE}/Contents/MacOS/"
cp _IosevkaThin-terminal.ttf "${BUNDLE}/Contents/MacOS/"
# Shell configs (loaded relative to binary)
cp -R shell "${BUNDLE}/Contents/MacOS/shell"
# Remove .zsh_history from bundle
rm -f "${BUNDLE}/Contents/MacOS/shell/.zsh_history"
# Icon
cp AppIcon.icns "${BUNDLE}/Contents/Resources/"
# Onboarding video
cp SystemTrayTerminal.mp4 "${BUNDLE}/Contents/Resources/"
# PkgInfo
echo -n "APPL????" > "${BUNDLE}/Contents/PkgInfo"
# Info.plist
cat > "${BUNDLE}/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>${APP_NAME}</string>
<key>CFBundleDisplayName</key>
<string>SystemTrayTerminal</string>
<key>CFBundleIdentifier</key>
<string>${BUNDLE_ID}</string>
<key>CFBundleVersion</key>
<string>${VERSION}</string>
<key>CFBundleShortVersionString</key>
<string>${VERSION}</string>
<key>CFBundleExecutable</key>
<string>${APP_NAME}</string>
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>LSMinimumSystemVersion</key>
<string>12.0</string>
<key>LSUIElement</key>
<true/>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSSupportsAutomaticTermination</key>
<false/>
<key>NSSupportsSuddenTermination</key>
<false/>
<key>NSAppleEventsUsageDescription</key>
<string>SystemTrayTerminal needs accessibility access for the global hotkey.</string>
</dict>
</plist>
PLIST
echo " Bundle assembled"
# ─── Step 4: Summary ───
echo "[4/4] Done!"
echo ""
TOTAL_SIZE=$(du -sh "$BUNDLE" | cut -f1)
BIN_SIZE=$(ls -lh "${BUNDLE}/Contents/MacOS/${APP_NAME}" | awk '{print $5}')
echo " ${BUNDLE} → ${TOTAL_SIZE} total (binary: ${BIN_SIZE})"
echo " Run with: open ${BUNDLE}"
echo " Install: cp -R ${BUNDLE} /Applications/"