Last active
May 8, 2021 17:55
-
-
Save Phate6660/33f5e213660e799c5692ac382765e7bc to your computer and use it in GitHub Desktop.
A snippet to display music info from MPD or Spotify.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$(playerctl -p spotify,mpd metadata -f "{{ playerName }}")" == "mpd" ]; then | |
dunstify "$(echo -e "$(playerctl -p spotify,mpd metadata -f "Player: {{ playerName }}\n\nTIT: {{ title }}\nALB: {{ album }}\nART: {{ artist }}")")" -I "/tmp/cover.png" | |
elif [ "$(playerctl -p spotify,mpd metadata -f "{{ playerName }}")" == "spotify" ]; then | |
id="$(basename "$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:Metadata | awk -F '"' 'BEGIN {RS=" entry"}; /"mpris:artUrl"/ {a = $4} END {print a}')")" | |
url="https://i.scdn.co/image/$id" | |
curl "$url" -o "/tmp/cover-spotify.jpg" | |
dunstify "$(echo -e "$(playerctl -p spotify,mpd metadata -f "Player: {{ playerName }}\n\nTIT: {{ title }}\nALB: {{ album }}\nART: {{ artist }}")")" -I "/tmp/cover-spotify.jpg" | |
else | |
dunstify "$(echo -e "$(playerctl -p spotify,mpd metadata -f "Player: {{ playerName }}\n\nTIT: {{ title }}\nALB: {{ album }}\nART: {{ artist }}")")" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output:
