#!/bin/sh

export LD_LIBRARY_PATH="/usr/$LIBDIR/apulse"

if command -v spotify-dbus.py > /dev/null; then
	echo "Launching spotify with Gnome systray integration."
	spotify-dbus.py "$@"
elif command -v spotify-tray > /dev/null; then
	echo "Launching spotify with generic systray integration."
	minimized=
	for arg; do
		if [ "$arg" = --minimized ]; then
			minimized=$arg
			break
		fi
	done
	spotify-tray \
		--client-path="$SPOTIFY_HOME/spotify" --toggle $minimized -- "$@"
else
	echo "Neither gnome-integration-spotify nor spotify-tray are installed."
	echo "Launching spotify without systray integration."
	exec "$SPOTIFY_HOME/spotify" "$@"
fi
