summaryrefslogtreecommitdiff
path: root/media-sound/spotify/files/spotify-wrapper
blob: 862fa4c680d6e1e87a1398011b3b09b8567fe60a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/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 [ -e "$SPOTIFY_HOME/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
        GDK_BACKEND="x11" "$SPOTIFY_HOME/spotify-tray" \
                --client-path="$SPOTIFY_HOME/spotify" --toggle $minimized -- "$@"
else
    if pgrep -f "Spotify/[0-9].[0-9].[0-9]" > /dev/null; then
        busline="org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.OpenUri ${1}"
        echo "Spotify is already running"
        echo "Sending ${busline} to dbus"
        if command -v qdbus &> /dev/null; then
            qdbus $busline
            exit
        fi
        if command -v dbus-send &> /dev/null; then
            dbus-send $busline
            exit
        fi
        echo "No bus dispatcher found."
    else
        echo "Neither gnome-integration-spotify nor spotify-tray are installed."
        echo "Launching spotify without systray integration."
        exec "$SPOTIFY_HOME/spotify" "$@"
    fi
fi