Skip to content

Instantly share code, notes, and snippets.

@RobertAudi
Created July 5, 2010 18:50
Show Gist options
  • Select an option

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

Select an option

Save RobertAudi/464598 to your computer and use it in GitHub Desktop.
Script used to show info about the song playing in moc using GeekTool on OS X
#!/bin/bash
# First let's check if moc is running...
if [[ $(ps aux | grep mocp | grep -v grep | wc -l) -gt 0 ]];
then
out=$(/opt/local/bin/mocp -i)
# 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"
if [[ $1 ]]
then
case "$1" in
'artist'|'ARTIST'|'Artist')
echo $artist
;;
'song'|'SONG'|'Song')
echo $title
;;
'album'|'ALBUM'|'Album')
echo $album
;;
*)
echo "$1"
;;
esac
else
echo "$title by $artist (album: $album)"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment