cmus-artist-title.sh 972 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. #
  4. # cmus-status-display
  5. #
  6. # Usage:
  7. # in cmus command ":set status_display_program=cmus-status-display"
  8. #
  9. # This scripts is executed by cmus when status changes:
  10. # cmus-status-display key1 val1 key2 val2 ...
  11. #
  12. # All keys contain only chars a-z. Values are UTF-8 strings.
  13. #
  14. # Keys: status file url artist album discnumber tracknumber title date
  15. # - status (stopped, playing, paused) is always given
  16. # - file or url is given only if track is 'loaded' in cmus
  17. # - other keys/values are given only if they are available
  18. #
  19. output()
  20. {
  21. # write status to ~/cmus-status.txt (not very useful though)
  22. echo "$*" >> ~/cmus-status.txt 2>&1
  23. # WMI (http://wmi.modprobe.de/)
  24. #wmiremote -t "$*" &> /dev/null
  25. }
  26. while test $# -ge 2
  27. do
  28. eval _$1='$2'
  29. shift
  30. done
  31. if test -n "$_file"; then
  32. output "$_artist - $_title"
  33. elif test -n "$_url"; then
  34. output "$_title"
  35. else
  36. output "[$_status]"
  37. fi