Advertisement
Guest User

np.sh

a guest
Mar 1st, 2017
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #!/bin/bash
  2. # Now playing script for CMUS
  3. # Provides artist, album, title, and optionally time / duration
  4. # Adapted from: http://v3gard.com/2011/01/getting-cmus-to-cooperate-with-conky/
  5.  
  6. convertsecs() {
  7. ((h=${1}/3600))
  8. ((m=(${1}%3600)/60))
  9. ((s=${1}%60))
  10. printf "%02d:%02d\n" $m $s
  11. }
  12.  
  13.  
  14. if [ ! -x /usr/bin/cmus-remote ]; then
  15. echo "cmus is not installed."
  16. exit
  17. fi
  18.  
  19. ARTIST=$( cmus-remote -Q 2>/dev/null | grep artist | cut -d " " -f 3- | sed -n 1p)
  20. TITLE=$( cmus-remote -Q 2>/dev/null | grep title | cut -d " " -f 3- )
  21. ALBUM=$( cmus-remote -Q | grep album | cut -d " " -f 3- | sed -n 1p )
  22. TIME=$( cmus-remote -Q | grep position | cut -d " " -f 2- | sed -n 1p )
  23. DUR=$( cmus-remote -Q | grep duration | cut -d " " -f 2- )
  24.  
  25. if [ -z "$ARTIST" ];then
  26. echo ""
  27. else
  28. echo "| $ARTIST / $ALBUM / $TITLE | $( convertsecs $TIME ) / $( convertsecs $DUR)"
  29. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement