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.
 
 
 
 
 

26 lines
593 B

#!/usr/bin/env elvish
if (eq (mpc current) "") { exit 1 }
library-location = (xdg-user-dir MUSIC)
song-relative = (mpc -f '%file%' | take 1)
song-location = $library-location'/'$song-relative
song-dir = (path-dir $song-location)
@images = (fd -t f -e png -e jpg -e jpeg . $song-dir)
if (> (count $images) 0) {
use str
image = ""
for i $images {
t = (str:to-lower (joins . [(splits . (path-base $i))][:-1]))
if (or (eq $t "cover") \
(eq $t "folder")) { image = $i }
}
if (eq $image '') {
print $images[0]
} else {
print $image
}
} else {
exit 1
}