cmus.sh 698 B

123456789101112131415161718192021
  1. #!/bin/bash
  2. prepend_zero () {
  3. seq -f "%02g" $1 $1
  4. }
  5. artist=$(echo -n $(cmus-remote -C status | grep "tag artist" | cut -c 12-))
  6. if [[ $artist = *[!\ ]* ]]; then
  7. song=$(echo -n $(cmus-remote -C status | grep title | cut -c 11-))
  8. position=$(cmus-remote -C status | grep position | cut -c 10-)
  9. minutes1=$(prepend_zero $(($position / 60)))
  10. seconds1=$(prepend_zero $(($position % 60)))
  11. duration=$(cmus-remote -C status | grep duration | cut -c 10-)
  12. minutes2=$(prepend_zero $(($duration / 60)))
  13. seconds2=$(prepend_zero $(($duration % 60)))
  14. echo -n "$artist - $song [$minutes1:$seconds1/$minutes2:$seconds2]"
  15. else
  16. echo
  17. fi