Created
July 23, 2025 09:30
-
-
Save S1M0N38/4653c532bf048474100df3a270822bb4 to your computer and use it in GitHub Desktop.
Start Balatro with Mods in backgroud with MacOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if running on macOS | |
if [[ "$OSTYPE" != "darwin"* ]]; then | |
echo "Error: This script is only supported on macOS" >&2 | |
exit 1 | |
fi | |
# Cleanup function for signal handling | |
cleanup() { | |
echo "Script interrupted. Cleaning up..." | |
exit 1 | |
} | |
# Trap signals for cleanup | |
trap cleanup SIGINT SIGTERM | |
# Check if Balatro is currently running | |
echo "Checking if Balatro is running..." | |
if ps aux | grep -E "(Balatro\.app|balatro\.sh)" | grep -v grep >/dev/null; then | |
echo "Balatro is running. Killing existing process..." | |
pkill -f "Balatro\.app" | |
pkill -f "balatro\.sh" | |
sleep 2 | |
# Verify process was killed | |
if ps aux | grep -E "(Balatro\.app|balatro\.sh)" | grep -v grep >/dev/null; then | |
echo "Force killing Balatro process..." | |
pkill -9 -f "Balatro\.app" | |
pkill -9 -f "balatro\.sh" | |
sleep 1 | |
fi | |
echo "Existing Balatro process terminated." | |
else | |
echo "No existing Balatro process found." | |
fi | |
# Delete previous log file | |
if [ -f "balatro.log" ]; then | |
echo "Removing previous balatro.log..." | |
rm balatro.log | |
fi | |
# Start Balatro in background | |
echo "Starting Balatro in background..." | |
balatro_path="/Users/$USER/Library/Application Support/Steam/steamapps/common/Balatro" | |
export DYLD_INSERT_LIBRARIES="$balatro_path/liblovely.dylib" | |
# Start the process and capture PID | |
"$balatro_path/Balatro.app/Contents/MacOS/love" "$@" >balatro.log 2>&1 & | |
BALATRO_PID=$! | |
echo "Balatro started with PID: $BALATRO_PID" | |
# Verify process is running | |
sleep 2 | |
if ! ps -p $BALATRO_PID >/dev/null; then | |
echo "ERROR: Balatro failed to start. Check balatro.log for details." | |
exit 1 | |
fi | |
echo "Balatro is running successfully!" | |
echo "PID: $BALATRO_PID" | |
echo "Log file: balatro.log" | |
# Monitor startup for success indicators | |
echo "Monitoring startup (timeout: 30 seconds)..." | |
timeout=30 | |
elapsed=0 | |
while [ $elapsed -lt $timeout ]; do | |
if [ -f "balatro.log" ]; then | |
if grep -q "BalatroBot loaded" balatro.log; then | |
echo "SUCCESS: BalatroBot mod loaded successfully!" | |
break | |
elif grep -q "BalatrobotAPI initialized" balatro.log; then | |
echo "SUCCESS: BalatrobotAPI initialized!" | |
break | |
elif grep -q "TCP socket created on port 12346" balatro.log; then | |
echo "SUCCESS: TCP socket created!" | |
break | |
fi | |
fi | |
# Check if process is still running | |
if ! ps -p $BALATRO_PID >/dev/null; then | |
echo "ERROR: Balatro process crashed during startup. Check balatro.log for details." | |
exit 1 | |
fi | |
sleep 1 | |
elapsed=$((elapsed + 1)) | |
done | |
if [ $elapsed -ge $timeout ]; then | |
echo "WARNING: Startup verification timed out. Check balatro.log manually." | |
echo "Common success indicators to look for:" | |
echo " - 'BalatrobotAPI initialized'" | |
echo " - 'BalatroBot loaded - version X.X.X'" | |
echo " - 'TCP socket created on port 12346'" | |
fi | |
echo "" | |
echo "Balatro is ready for development!" | |
echo "PID: $BALATRO_PID (use 'kill $BALATRO_PID' to stop)" | |
echo "Logs saved to the file balatro.log" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment