Skip to content

Commit e3cb5d4

Browse files
try to get the app to launch in a persistent window
1 parent 006a7fb commit e3cb5d4

5 files changed

Lines changed: 63 additions & 2 deletions

File tree

Scripts/package_app.py

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,62 @@
1515
import json
1616
from pathlib import Path
1717

18+
def setup_macos_launcher_hack(app_bundle_path):
19+
"""
20+
Implement the launcher script hack for macOS to get persistent terminal
21+
Based on the original packaging approach
22+
"""
23+
print("Setting up macOS launcher script hack...")
24+
25+
macos_dir = app_bundle_path / "Contents" / "MacOS"
26+
original_executable = macos_dir / "Jumperless"
27+
cli_executable = macos_dir / "Jumperless_cli"
28+
29+
if not original_executable.exists():
30+
print(f"Warning: Original executable not found: {original_executable}")
31+
return
32+
33+
# Rename the original executable to Jumperless_cli
34+
if cli_executable.exists():
35+
cli_executable.unlink()
36+
original_executable.rename(cli_executable)
37+
print(f"Renamed {original_executable} to {cli_executable}")
38+
39+
# Create launcher script
40+
launcher_script_content = '''#!/bin/bash
41+
# Jumperless macOS Launcher
42+
# Opens Terminal and runs the CLI application
43+
44+
# Get the directory of this script (inside the app bundle)
45+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
46+
CLI_EXECUTABLE="$SCRIPT_DIR/Jumperless_cli"
47+
48+
# Check if CLI executable exists
49+
if [ ! -f "$CLI_EXECUTABLE" ]; then
50+
echo "Error: CLI executable not found at $CLI_EXECUTABLE"
51+
exit 1
52+
fi
53+
54+
# Use AppleScript to open Terminal and run the CLI app
55+
osascript -e "
56+
tell application \\"Terminal\\"
57+
activate
58+
set newWindow to do script \\"\\"
59+
delay 0.5
60+
do script \\"cd '$SCRIPT_DIR' && ./Jumperless_cli\\" in newWindow
61+
set bounds of front window to {100, 100, 1000, 700}
62+
end tell
63+
"
64+
'''
65+
66+
# Write launcher script
67+
with open(original_executable, 'w') as f:
68+
f.write(launcher_script_content)
69+
70+
# Make launcher script executable
71+
os.chmod(original_executable, 0o755)
72+
print(f"Created launcher script at {original_executable}")
73+
1874
def create_python_fallback(platform, arch, output_dir):
1975
"""Create Python fallback package with launcher script"""
2076
print(f"Creating Python fallback package for {platform}-{arch}")
@@ -273,13 +329,16 @@ def package_platform(platform, arch, output_dir):
273329

274330
# Copy executable if it exists
275331
if platform == "macos":
276-
# Handle .app bundle for macOS
332+
# Handle .app bundle for macOS with launcher script hack
277333
app_bundle_name = "Jumperless.app"
278334
app_bundle_path = Path(f"dist/{platform}/{app_bundle_name}")
279335
if app_bundle_path.exists():
280336
# Copy the entire .app bundle
281337
shutil.copytree(app_bundle_path, platform_dir / app_bundle_name, dirs_exist_ok=True)
282338
print(f"Copied .app bundle: {app_bundle_name}")
339+
340+
# Implement launcher script hack for persistent terminal
341+
setup_macos_launcher_hack(platform_dir / app_bundle_name)
283342
else:
284343
print(f"Warning: .app bundle not found: {app_bundle_path}")
285344
else:
@@ -417,12 +476,14 @@ def create_platform_readme(platform_dir, platform):
417476
'''
418477
elif platform == "macos":
419478
readme_content += '''
420-
Double-click `Jumperless.app` in Finder to run.
479+
Double-click `Jumperless.app` in Finder to run. This will open a new Terminal window and run the Jumperless CLI application.
421480
422481
Or open from Terminal:
423482
```bash
424483
open Jumperless.app
425484
```
485+
486+
The app will automatically launch in a new Terminal window for the best CLI experience.
426487
'''
427488
elif platform == "windows":
428489
readme_content += '''

0 commit comments

Comments
 (0)