From 73b0e4c786a412999f185f19647bc5f3a2dbdeb0 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 4 Mar 2016 12:32:06 +1100 Subject: [PATCH] [Linux] Added spotify support to getsong --- neofetch | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 69809928..caf13d73 100755 --- a/neofetch +++ b/neofetch @@ -1075,6 +1075,21 @@ getsong () { song="$(mocp -Q "%artist - %song" 2>/dev/null)" state="$(mocp -Q "%state" 2>/dev/null)" + elif pgrep "spotify" >/dev/null 2>&1; then + case "$os" in + "Linux") + # This command is way too long + song="$(\ + 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 'string "' '/string|array/ {printf "%s",$2; next}{print ""}' |\ + awk -F '"' '/artist|title/ {printf $2 " - "}'\ + )" + song=${song% - } + song=${song/'('*} + song=${song//'['*} + ;; + esac else song="Unknown" fi @@ -1084,7 +1099,7 @@ getsong () { song="Paused" ;; - "stopped" | "STOP" | "") + "stopped" | "STOP") song="Stopped" ;; esac