From edeabd877f30c68dd56a850d273c766e5efaef2c Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 4 Jan 2017 00:40:36 -0500 Subject: [PATCH] shell/mpd/bin/notify-song.sh: polish output + notifications --- shell/mpd/bin/notify-song.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/shell/mpd/bin/notify-song.sh b/shell/mpd/bin/notify-song.sh index 2d28f485..d4c4d8b6 100755 --- a/shell/mpd/bin/notify-song.sh +++ b/shell/mpd/bin/notify-song.sh @@ -5,17 +5,21 @@ if ! pgrep mpd >/dev/null; then exit 1 fi -info=$(mpc current) -if [[ -z $info ]]; then +info=$(mpc -f ";%artist%;%album%;%title%") +if [[ -z $info || ${info:0:1} != ";" ]]; then >&2 echo "nothing is playing." exit fi +artist=$(awk -F';' '{ print $2 }' <<<"$info") +album=$(awk -F';' '{ print $3 }' <<<"$info") +title=$(awk -F';' '{ print $4 }' <<<"$info") + case $OSTYPE in darwin*) - terminal-notifier -title "Now playing" -message "$info" -appIcon "/Applications/iTunes.app/Contents/Resources/iTunes.icns" + terminal-notifier -title "$title" -message "by $artist\n$album" -appIcon "/Applications/iTunes.app/Contents/Resources/iTunes.icns" ;; linux*) - notify-send --icon="media-playback-start" --app-name="ncmpcpp" "Now playing" "$info" + notify-send --icon="media-playback-start" --app-name="ncmpcpp" "$title" "$artist\n$album" ;; esac