Guest User

Pianobar Notifications (Ubuntu)

a guest
Apr 14th, 2011
802
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # create variables
  3. while read L; do
  4. k="`echo "$L" | cut -d '=' -f 1`"
  5. v="`echo "$L" | cut -d '=' -f 2`"
  6. export "$k=$v"
  7. done < <(grep -e '^\(title\|artist\|album\|stationName\|pRet\|pRetStr\|wRet\|wRetStr\|songDuration\|songPlayed\|rating\|coverArt\)=' /dev/stdin) # don't overwrite $1...
  8.  
  9. case "$1" in
  10. songstart)
  11. # echo 'naughty.notify({title = "pianobar", text = "Now playing: ' "$title" ' by ' "$artist" '"})' | awesome-client -
  12. # echo "$title -- $artist" > $HOME/.config/pianobar/nowplaying
  13. # # or whatever you like...
  14. notify-send "Pianobar - $stationName" "Now Playing: $artist - $title"
  15. ;;
  16.  
  17. # songfinish)
  18. # # scrobble if 75% of song have been played, but only if the song hasn't
  19. # # been banned
  20. # if [ -n "$songDuration" ] &&
  21. # [ $(echo "scale=4; ($songPlayed/$songDuration*100)>50" | bc) -eq 1 ] &&
  22. # [ "$rating" -ne 2 ]; then
  23. # # scrobbler-helper is part of the Audio::Scrobble package at cpan
  24. # # "pia" is the last.fm client identifier of "pianobar", don't use
  25. # # it for anything else, please
  26. # scrobbler-helper -P pia -V 1.0 "$title" "$artist" "$album" "" "" "" "$((songDuration/1000))" &
  27. # fi
  28. # ;;
  29.  
  30. *)
  31. if [ "$pRet" -ne 1 ]; then
  32. notify-send "Pianobar - ERROR" "$1 failed: $pRetStr"
  33. elif [ "$wRet" -ne 1 ]; then
  34. notify-send "Pianobar - ERROR" "$1 failed: $wRetStr"
  35. fi
  36. ;;
  37. esac
RAW Paste Data