Skip to content

Instantly share code, notes, and snippets.

@Leask
Created May 15, 2018 09:32
Show Gist options
  • Save Leask/37abe8fbf58bad652ec88a1478c1a4ce to your computer and use it in GitHub Desktop.
Save Leask/37abe8fbf58bad652ec88a1478c1a4ce to your computer and use it in GitHub Desktop.
Get current listening on iTunes.
#!/bin/sh
# Flora Listening by LeaskH.com
initFlora() {
export PATH=~/Documents/.flora:$PATH
}
getLastListening() {
echo `cat /tmp/flora_listening 2> /dev/null`
}
setLastListening() {
echo "$*" > /tmp/flora_listening
}
getCurListening() {
echo "`itunes status | sed -n 2p`"
}
# Main logic
initFlora
current="`getCurListening`"
if [ "$1" = 's' ]; then
if [ ! "`getLastListening`" = "$current" ]; then
notify $current
# itunes lyric
fi
else
notify $current
# itunes lyric
fi
setLastListening $current
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment