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.

get-song-cover 593B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env elvish
  2. if (eq (mpc current) "") { exit 1 }
  3. library-location = (xdg-user-dir MUSIC)
  4. song-relative = (mpc -f '%file%' | take 1)
  5. song-location = $library-location'/'$song-relative
  6. song-dir = (path-dir $song-location)
  7. @images = (fd -t f -e png -e jpg -e jpeg . $song-dir)
  8. if (> (count $images) 0) {
  9. use str
  10. image = ""
  11. for i $images {
  12. t = (str:to-lower (joins . [(splits . (path-base $i))][:-1]))
  13. if (or (eq $t "cover") \
  14. (eq $t "folder")) { image = $i }
  15. }
  16. if (eq $image '') {
  17. print $images[0]
  18. } else {
  19. print $image
  20. }
  21. } else {
  22. exit 1
  23. }