1+ #!/usr/bin/env python3
2+ """
3+ Setup macOS Launcher Script Hack
4+ Applies the launcher script hack BEFORE code signing and notarization
5+ """
6+
7+ import os
8+ import shutil
9+ from pathlib import Path
10+
11+ def setup_macos_launcher_hack ():
12+ """
13+ Implement the launcher script hack for macOS to get persistent terminal
14+ This happens BEFORE code signing so the signature applies to the final version
15+ """
16+ print ("Setting up macOS launcher script hack..." )
17+
18+ app_path = Path ("dist/macos/Jumperless.app" )
19+ if not app_path .exists ():
20+ print (f"Warning: App bundle not found at { app_path } " )
21+ return False
22+
23+ macos_dir = app_path / "Contents" / "MacOS"
24+ original_executable = macos_dir / "Jumperless"
25+ cli_executable = macos_dir / "Jumperless_cli"
26+
27+ if not original_executable .exists ():
28+ print (f"Warning: Original executable not found at { original_executable } " )
29+ return False
30+
31+ # Rename the original executable to Jumperless_cli
32+ if cli_executable .exists ():
33+ cli_executable .unlink ()
34+ shutil .move (str (original_executable ), str (cli_executable ))
35+ print (f"Renamed { original_executable } to { cli_executable } " )
36+
37+ # Create launcher script content
38+ launcher_script_content = '''#!/bin/bash
39+ # Jumperless macOS Launcher
40+ # Opens Terminal and runs the CLI application
41+
42+ # Get the directory of this script (inside the app bundle)
43+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
44+ CLI_EXECUTABLE="$SCRIPT_DIR/Jumperless_cli"
45+
46+ # Check if CLI executable exists
47+ if [ ! -f "$CLI_EXECUTABLE" ]; then
48+ echo "Error: CLI executable not found at $CLI_EXECUTABLE"
49+ exit 1
50+ fi
51+
52+ # Use AppleScript to open Terminal and run the CLI app
53+ osascript -e "
54+ tell application \\ "Terminal\\ "
55+ activate
56+ set newWindow to do script \\ "\\ "
57+ delay 0.5
58+ do script \\ "cd '$SCRIPT_DIR' && ./Jumperless_cli\\ " in newWindow
59+ set bounds of front window to {100, 100, 1000, 700}
60+ end tell
61+ "
62+ '''
63+
64+ # Write launcher script
65+ with open (original_executable , 'w' ) as f :
66+ f .write (launcher_script_content )
67+
68+ # Make launcher script executable
69+ os .chmod (original_executable , 0o755 )
70+ print (f"Created launcher script at { original_executable } " )
71+
72+ return True
73+
74+ if __name__ == "__main__" :
75+ success = setup_macos_launcher_hack ()
76+ if success :
77+ print ("macOS launcher script hack applied successfully" )
78+ else :
79+ print ("Failed to apply macOS launcher script hack" )
80+ exit (1 )
0 commit comments