Configuration file for dwm-bar on macbook air
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB

  1. #!/bin/sh
  2. # A dwm_bar function that shows the current artist, track, position, duration, and status from cmus
  3. # Joe Standring <git@joestandring.com>
  4. # GNU GPLv3
  5. # Dependencies: cmus
  6. dwm_cmus () {
  7. if ps -C cmus > /dev/null; then
  8. ARTIST=$(cmus-remote -Q | grep -a '^tag artist' | awk '{gsub("tag artist ", "");print}')
  9. TRACK=$(cmus-remote -Q | grep -a '^tag title' | awk '{gsub("tag title ", "");print}')
  10. POSITION=$(cmus-remote -Q | grep -a '^position' | awk '{gsub("position ", "");print}')
  11. DURATION=$(cmus-remote -Q | grep -a '^duration' | awk '{gsub("duration ", "");print}')
  12. STATUS=$(cmus-remote -Q | grep -a '^status' | awk '{gsub("status ", "");print}')
  13. SHUFFLE=$(cmus-remote -Q | grep -a '^set shuffle' | awk '{gsub("set shuffle ", "");print}')
  14. if [ "$IDENTIFIER" = "unicode" ]; then
  15. if [ "$STATUS" = "playing" ]; then
  16. STATUS="▶"
  17. else
  18. STATUS="⏸"
  19. fi
  20. if [ "$SHUFFLE" = "true" ]; then
  21. SHUFFLE=" 🔀"
  22. else
  23. SHUFFLE=""
  24. fi
  25. else
  26. if [ "$STATUS" = "playing" ]; then
  27. STATUS="PLA"
  28. else
  29. STATUS="PAU"
  30. fi
  31. if [ "$SHUFFLE" = "true" ]; then
  32. SHUFFLE=" S"
  33. else
  34. SHUFFLE=""
  35. fi
  36. fi
  37. printf "%s %s - %s " "$STATUS" "$ARTIST" "$TRACK"
  38. printf "%0d:%02d/" $((POSITION%3600/60)) $((POSITION%60))
  39. printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60))
  40. printf "%s\n" "$SHUFFLE"
  41. fi
  42. }
  43. dwm_cmus