aboutsummaryrefslogtreecommitdiff
path: root/scripts/spotify-artist-title.sh
blob: 62494b85554c4756530d89b6e8794432bd8fbc01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash

metadata=$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata')

if [[ $metadata == *"spotify:ad"* ]]
then
    echo "ad :/"
else
    artist=$(echo "$metadata" | egrep -A 2 "artist" | egrep -v "artist" | egrep -v "array" | cut -b 27- | cut -d '"' -f 1 | egrep -v ^$)

    title=$(echo "$metadata" | egrep -A 1 "title" | egrep -v "title" | cut -b 44- | cut -d '"' -f 1| egrep -v ^$)

    echo $artist - $title
fi