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.

38 lines
1.1 KiB

4 years ago
  1. #!/bin/sh
  2. # A dwm_bar function that shows the current artist, track, duration, and status from Spotify using playerctl
  3. # Joe Standring <git@joestandring.com>
  4. # GNU GPLv3
  5. # Dependencies: spotify, playerctl
  6. # TODO: Find a method to get track position data and shuffle status (currently playerctl does not work for this)
  7. dwm_spotify () {
  8. if ps -C spotify > /dev/null; then
  9. ARTIST=$(playerctl -p spotify metadata artist)
  10. TRACK=$(playerctl -p spotify metadata title)
  11. DURATION=$(playerctl -p spotify metadata mpris:length | sed 's/.\{6\}$//')
  12. STATUS=$(playerctl -p spotify status)
  13. if [ "$IDENTIFIER" = "unicode" ]; then
  14. if [ "$STATUS" = "Playing" ]; then
  15. STATUS="▶"
  16. else
  17. STATUS="⏸"
  18. fi
  19. else
  20. if [ "$STATUS" = "Playing" ]; then
  21. STATUS="PLA"
  22. else
  23. STATUS="PAU"
  24. fi
  25. fi
  26. printf "%s%s %s - %s " "$SEP1" "$STATUS" "$ARTIST" "$TRACK"
  27. printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60))
  28. printf "%s\n" "$SEP2"
  29. fi
  30. }
  31. dwm_spotify