From d964207b3e3d7216c53a827c4aff94ffc683aab8 Mon Sep 17 00:00:00 2001 From: AeroSageMage Date: Sun, 17 Aug 2025 15:48:24 +0200 Subject: [PATCH] Add macOS launcher compatibility - Add cross-platform path handling for SimAPI files (Windows/macOS) - Create macOS launcher script (start_aerofly_map.sh) equivalent to Windows batch file - Use proper macOS paths: ~/Library/Application Support/SayIntentionsAI/ - Maintain backward compatibility with Windows LOCALAPPDATA paths - Enable macOS users to run the application with proper server startup --- python/udp_to_websocket.py | 8 +++++++- start_aerofly_map.sh | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100755 start_aerofly_map.sh diff --git a/python/udp_to_websocket.py b/python/udp_to_websocket.py index 030b680..d18cd3e 100644 --- a/python/udp_to_websocket.py +++ b/python/udp_to_websocket.py @@ -43,7 +43,13 @@ # SimAPI file paths - SayIntentionsAI reads from a specific location def get_local_appdata_path(): # Get the local appdata directory path where SayIntentionsAI expects SimAPI files - return os.path.join(os.environ.get('LOCALAPPDATA', ''), 'SayIntentionsAI') + # Cross-platform support for Windows and macOS + if os.name == 'nt': # Windows + return os.path.join(os.environ.get('LOCALAPPDATA', ''), 'SayIntentionsAI') + else: # macOS/Linux + # Use ~/Library/Application Support for macOS + home = os.path.expanduser('~') + return os.path.join(home, 'Library', 'Application Support', 'SayIntentionsAI') def ensure_simapi_dir(): # Ensure the SayIntentionsAI directory exists in local appdata diff --git a/start_aerofly_map.sh b/start_aerofly_map.sh new file mode 100755 index 0000000..8aaa280 --- /dev/null +++ b/start_aerofly_map.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +echo "Starting Aerofly Moving Map..." +echo + +# Start the UDP to WebSocket server in the background +echo "Starting UDP to WebSocket server..." +python3 python/udp_to_websocket.py & +UDP_PID=$! + +# Wait a moment for the first server to start +sleep 2 + +# Start the HTTP server in the background +echo "Starting HTTP server..." +python3 -m http.server 8080 & +HTTP_PID=$! + +# Wait a moment for the HTTP server to start +sleep 3 + +# Open the browser +echo "Opening browser..." +open http://localhost:8080/index.html + +echo +echo "Aerofly Moving Map is starting up!" +echo +echo "The following servers should now be running:" +echo "1. UDP to WebSocket Server (receives data from Aerofly FS 4) - PID: $UDP_PID" +echo "2. HTTP Server (serves the web page) - PID: $HTTP_PID" +echo "3. Browser with the moving map" +echo +echo "To stop the servers, press Ctrl+C or run: kill $UDP_PID $HTTP_PID" +echo + +# Wait for user input to stop +read -p "Press Enter to stop the servers..." +kill $UDP_PID $HTTP_PID +echo "Servers stopped."