#!/bin/bash
# Cosmos Cloud Launcher Script

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"

# Best effort: the app may live in a root-owned directory (/opt, /usr/local) where
# an unprivileged user cannot chmod. That is fine as long as the bit is already set.
for binary in ./data/flutter_assets/resources/constellation-linux-*; do
    [ -e "$binary" ] || continue
    [ -x "$binary" ] || chmod +x "$binary" 2>/dev/null || \
        echo "Warning: $binary is not executable and could not be made executable." >&2
done

# Keep the desktop entry pointing at wherever the app currently lives.
if [ -x ./install-desktop-entry.sh ]; then
    ./install-desktop-entry.sh >/dev/null 2>&1 || true
fi

# Launch the application
./cosmos_cloud
