-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild_ui.sh
More file actions
executable file
·117 lines (100 loc) · 4.16 KB
/
Copy pathbuild_ui.sh
File metadata and controls
executable file
·117 lines (100 loc) · 4.16 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
#!/bin/bash
set -e
VERSION="1.2.0"
echo "Building GearboxUI Swift App..."
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# --- Ensure Python venv is healthy ---
VENV_DIR="$PROJECT_DIR/venv"
VENV_BIN="$VENV_DIR/bin/python3"
if [ ! -f "$VENV_BIN" ] || ! "$VENV_BIN" -c "import click, apscheduler, cron_descriptor" 2>/dev/null; then
echo "Python environment missing or stale — rebuilding..."
rm -rf "$VENV_DIR"
python3.11 -m venv "$VENV_DIR"
"$VENV_BIN" -m pip install -q --upgrade pip
"$VENV_BIN" -m pip install -q -r "$PROJECT_DIR/requirements.txt"
echo "Python environment ready."
fi
# -------------------------------------
cd "$PROJECT_DIR/GearboxUI"
swift build -c release
mkdir -p build/GearboxUI.app/Contents/MacOS
cp .build/release/GearboxUI build/GearboxUI.app/Contents/MacOS/
echo "Generating AppIcon..."
mkdir -p build/GearboxUI.app/Contents/Resources
ICONSET_DIR="build/AppIcon.iconset"
mkdir -p "$ICONSET_DIR"
if [ -f "Resources/AppIcon.png" ]; then
sips -z 16 16 Resources/AppIcon.png --out "$ICONSET_DIR/icon_16x16.png" > /dev/null
sips -z 32 32 Resources/AppIcon.png --out "$ICONSET_DIR/icon_16x16@2x.png" > /dev/null
sips -z 32 32 Resources/AppIcon.png --out "$ICONSET_DIR/icon_32x32.png" > /dev/null
sips -z 64 64 Resources/AppIcon.png --out "$ICONSET_DIR/icon_32x32@2x.png" > /dev/null
sips -z 128 128 Resources/AppIcon.png --out "$ICONSET_DIR/icon_128x128.png" > /dev/null
sips -z 256 256 Resources/AppIcon.png --out "$ICONSET_DIR/icon_128x128@2x.png" > /dev/null
sips -z 256 256 Resources/AppIcon.png --out "$ICONSET_DIR/icon_256x256.png" > /dev/null
sips -z 512 512 Resources/AppIcon.png --out "$ICONSET_DIR/icon_256x256@2x.png" > /dev/null
sips -z 512 512 Resources/AppIcon.png --out "$ICONSET_DIR/icon_512x512.png" > /dev/null
sips -z 1024 1024 Resources/AppIcon.png --out "$ICONSET_DIR/icon_512x512@2x.png" > /dev/null
iconutil -c icns "$ICONSET_DIR" -o build/GearboxUI.app/Contents/Resources/AppIcon.icns
rm -rf "$ICONSET_DIR"
else
echo "Warning: Resources/AppIcon.png not found. AppIcon will not be generated."
fi
cat > build/GearboxUI.app/Contents/Info.plist <<EOF
<?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>CFBundleExecutable</key>
<string>GearboxUI</string>
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<key>CFBundleIdentifier</key>
<string>com.gearbox.ui</string>
<key>CFBundleName</key>
<string>Gearbox</string>
<key>CFBundleShortVersionString</key>
<string>$VERSION</string>
<key>CFBundleVersion</key>
<string>7</string>
<key>LSUIElement</key>
<true/>
<key>NSUserNotificationUsageDescription</key>
<string>Gearbox uses notifications to alert you when scheduled tasks complete or fail.</string>
</dict>
</plist>
EOF
echo "Applying Ad-Hoc Code Signature to bypass AMFI..."
codesign --force --deep -s - "build/GearboxUI.app"
echo "Updating LaunchAgents for Gearbox..."
DAEMON_PLIST="$HOME/Library/LaunchAgents/com.gearbox.daemon.plist"
UI_PLIST="$HOME/Library/LaunchAgents/com.gearbox.ui.plist"
LAUNCH_DOMAIN="gui/$(id -u)"
GEARBOX_HOME="$HOME/.gearbox"
mkdir -p "$GEARBOX_HOME"
launchctl bootout "$LAUNCH_DOMAIN" "$DAEMON_PLIST" 2>/dev/null || true
launchctl bootout "$LAUNCH_DOMAIN" "$UI_PLIST" 2>/dev/null || true
rm -f "$DAEMON_PLIST"
cat > "$UI_PLIST" <<EOF
<?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>Label</key>
<string>com.gearbox.ui</string>
<key>ProgramArguments</key>
<array>
<string>$PROJECT_DIR/GearboxUI/build/GearboxUI.app/Contents/MacOS/GearboxUI</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>StandardErrorPath</key>
<string>$GEARBOX_HOME/ui-error.log</string>
<key>StandardOutPath</key>
<string>$GEARBOX_HOME/ui.log</string>
</dict>
</plist>
EOF
launchctl bootstrap "$LAUNCH_DOMAIN" "$UI_PLIST"
echo "Done! The Native macOS Menu Bar UI is now running!"