#!/bin/sh
# Full Spotify GUI client. Installed to /usr/local/bin/spotify-launch.
#
# The real, official Spotify Linux client — its own library browser, search and
# playlists — not spotifyd/librespot. Those are the thin client's and audio-endpoint's
# headless Spotify Connect *receivers*, which have no UI at all; this machine is sat in
# front of with a remote in hand, so it wants the browsable app, same as the touch
# panel. Spotify ships no apt package, so it comes from Flathub
# (0400-flatpak-apps.hook.chroot installs it).
#
# Login is interactive, on-device, on first launch (a Spotify account is needed;
# Premium for playback). The Flatpak's persistent data directory
# (~/.var/app/com.spotify.Client) keeps that session across restarts.
#
# Started lazily — see media-session. Spotify is one of the two apps that measurably
# costs a running game something if it sits in the background, which is most of why the
# media half of this image does not start at boot.
set -eu

if ! flatpak info com.spotify.Client >/dev/null 2>&1; then
  echo "spotify-launch: Spotify is not installed. Install it with:" >&2
  echo "  flatpak install -y flathub com.spotify.Client" >&2
  exit 1
fi

exec flatpak run com.spotify.Client "$@"
