Skip to content

Instantly share code, notes, and snippets.

@RobertAudi
Last active September 5, 2015 08:45
Show Gist options
  • Select an option

  • Save RobertAudi/465244 to your computer and use it in GitHub Desktop.

Select an option

Save RobertAudi/465244 to your computer and use it in GitHub Desktop.
Growl notifications for moc
#!/bin/bash
while out=$(/usr/local/Cellar/moc/2.5.0-beta1/bin/mocp -i); do
# Parse mocp output.
while IFS=: read -r field value; do
case $field in
Artist) artist=$value;;
Album) album=$value;;
SongTitle) title=$value;;
esac
done <<< "$out"
# Don't do anything if we're still on the same song.
[[ "$artist-$album-$title" = "$current" ]] && { sleep 1; continue; }
# Growl notify this information
if [[ $album && $artist && $title ]]; then
/usr/local/bin/growlnotify -t "moc: $title" -n "mocp" -m "by $artist"$'\n'"(album: $album)"
fi
# Remember the current song.
current="$artist-$album-$title"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment