Last active
September 5, 2015 08:45
-
-
Save RobertAudi/465244 to your computer and use it in GitHub Desktop.
Growl notifications for moc
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 | |
| 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