#!/bin/bash

# Simple installation script for GTK2 MPV Player

if [ "$EUID" -ne 0 ]; then
  echo "Please run as root (use sudo)"
  exit 1
fi

INSTALL_DIR="/usr/local/lib/gtk2-mpv-player"
BIN_LINK="/usr/local/bin/gtk2-mpv-player"
DESKTOP_FILE="/usr/share/applications/gtk2-mpv-player.desktop"

echo "Installing to $INSTALL_DIR..."

# Create directory
mkdir -p "$INSTALL_DIR"

# Copy binary and metadata
cp gtk2-mpv-player "$INSTALL_DIR/"
cp assets/icon.png "$INSTALL_DIR/"
cp -r lib "$INSTALL_DIR/"

# Create wrapper script
cat <<EOF > "$BIN_LINK"
#!/bin/bash
cd "$INSTALL_DIR"
./gtk2-mpv-player "\$@"
EOF

chmod +x "$BIN_LINK"

# Install desktop file
cp assets/gtk2-mpv-player.desktop "$DESKTOP_FILE"
# Update path in desktop file if needed (already set to /usr/local/bin/gtk2-mpv-player)

# Update MIME database
echo "Updating MIME database..."
update-desktop-database

echo "Installation complete!"
echo "You can now run 'gtk2-mpv-player' or find it in your application menu."
