159 lines
4.5 KiB
Bash
Executable File
159 lines
4.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# TechDJ PyQt5 Launcher Script
|
|
|
|
echo "🎧 TechDJ PyQt5 - Native DJ Application"
|
|
echo "========================================"
|
|
echo ""
|
|
|
|
# Check if Python is installed
|
|
if ! command -v python3 &> /dev/null; then
|
|
echo "❌ Python 3 is not installed!"
|
|
echo "Please install Python 3 first."
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ Python 3 found: $(python3 --version)"
|
|
|
|
# Check if pip is installed
|
|
if ! command -v pip3 &> /dev/null; then
|
|
echo "⚠️ pip3 not found. Installing..."
|
|
echo "Please run: sudo apt install python3-pip"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if dependencies are installed
|
|
echo ""
|
|
echo "Checking dependencies..."
|
|
|
|
MISSING_DEPS=0
|
|
|
|
# Check PyQt5
|
|
if ! python3 -c "import PyQt5" 2>/dev/null; then
|
|
echo "❌ PyQt5 not installed"
|
|
MISSING_DEPS=1
|
|
else
|
|
echo "✅ PyQt5 installed"
|
|
fi
|
|
|
|
# Check sounddevice
|
|
if ! python3 -c "import sounddevice" 2>/dev/null; then
|
|
echo "❌ sounddevice not installed"
|
|
MISSING_DEPS=1
|
|
else
|
|
echo "✅ sounddevice installed"
|
|
fi
|
|
|
|
# Check soundfile
|
|
if ! python3 -c "import soundfile" 2>/dev/null; then
|
|
echo "❌ soundfile not installed"
|
|
MISSING_DEPS=1
|
|
else
|
|
echo "✅ soundfile installed"
|
|
fi
|
|
|
|
# Check numpy
|
|
if ! python3 -c "import numpy" 2>/dev/null; then
|
|
echo "❌ numpy not installed"
|
|
MISSING_DEPS=1
|
|
else
|
|
echo "✅ numpy installed"
|
|
fi
|
|
|
|
# Check socketio
|
|
if ! python3 -c "import socketio" 2>/dev/null; then
|
|
echo "❌ python-socketio not installed"
|
|
MISSING_DEPS=1
|
|
else
|
|
echo "✅ python-socketio installed"
|
|
fi
|
|
|
|
# Install missing dependencies
|
|
if [ $MISSING_DEPS -eq 1 ]; then
|
|
if [[ "$*" == *"--noint"* ]]; then
|
|
echo "⚠️ Missing dependencies detected in non-interactive mode"
|
|
echo "Please run './launch_qt.sh' from terminal to install dependencies"
|
|
# Continue anyway - dependencies might be installed elsewhere
|
|
else
|
|
echo ""
|
|
echo "📦 Installing missing dependencies..."
|
|
echo "This may take a few minutes..."
|
|
echo ""
|
|
|
|
# Install system dependencies first (for sounddevice)
|
|
echo "Installing system dependencies..."
|
|
if command -v apt-get &> /dev/null; then
|
|
echo "Detected Debian/Ubuntu system"
|
|
echo "You may need to run: sudo apt-get install portaudio19-dev python3-pyqt5"
|
|
elif command -v dnf &> /dev/null; then
|
|
echo "Detected Fedora system"
|
|
echo "You may need to run: sudo dnf install portaudio-devel python3-qt5"
|
|
elif command -v pacman &> /dev/null; then
|
|
echo "Detected Arch system"
|
|
echo "You may need to run: sudo pacman -S portaudio python-pyqt5"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Installing Python packages..."
|
|
pip3 install --user PyQt5 sounddevice soundfile numpy python-socketio[client] requests
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Installation failed!"
|
|
echo "Please install dependencies manually:"
|
|
echo " pip3 install --user -r requirements.txt"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ Dependencies installed successfully!"
|
|
fi
|
|
fi
|
|
|
|
# Try to read server URL from settings
|
|
SERVER_URL="http://localhost:5000"
|
|
SETTINGS_FILE="$HOME/.techdj_settings.json"
|
|
|
|
if [ -f "$SETTINGS_FILE" ]; then
|
|
# Extract server_url from JSON if jq is available
|
|
if command -v jq &> /dev/null; then
|
|
SAVED_URL=$(jq -r '.server_url // "http://localhost:5000"' "$SETTINGS_FILE" 2>/dev/null)
|
|
if [ ! -z "$SAVED_URL" ] && [ "$SAVED_URL" != "null" ]; then
|
|
SERVER_URL="$SAVED_URL"
|
|
fi
|
|
else
|
|
# Fallback: simple grep if jq not available
|
|
SAVED_URL=$(grep -o '"server_url"[[:space:]]*:[[:space:]]*"[^"]*"' "$SETTINGS_FILE" 2>/dev/null | cut -d'"' -f4)
|
|
if [ ! -z "$SAVED_URL" ]; then
|
|
SERVER_URL="$SAVED_URL"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# Check if Flask server is running
|
|
echo "Checking server at: $SERVER_URL"
|
|
|
|
if curl -s --max-time 2 "${SERVER_URL}/library.json" > /dev/null 2>&1; then
|
|
echo "✅ Flask server is running at $SERVER_URL"
|
|
else
|
|
echo "⚠️ Flask server not detected at $SERVER_URL"
|
|
if [[ "$*" == *"--noint"* ]]; then
|
|
echo "Proceeding in non-interactive mode..."
|
|
else
|
|
echo "Please make sure the server is running."
|
|
echo ""
|
|
read -p "Continue anyway? (y/n) " -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
exit 1
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# Launch the application
|
|
echo ""
|
|
echo "🚀 Launching TechDJ PyQt5..."
|
|
echo ""
|
|
|
|
python3 techdj_qt.py
|
|
|
|
echo ""
|
|
echo "👋 TechDJ PyQt5 closed"
|