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.
33 lines
1.2 KiB
33 lines
1.2 KiB
killall -q playerctl
|
|
# delete all the copied image files first
|
|
find "$HOME/.config/ncspot/" -type f -exec sh -c 'file -b --mime-type "$0" | grep -q "^image/" && rm "$0"' {} \;
|
|
playerctl metadata --follow --format '{{ mpris:trackid }}' | while read -r line; do
|
|
title=$(playerctl metadata title)
|
|
album=$(playerctl metadata album)
|
|
artist=$(playerctl metadata artist)
|
|
art_url=$(playerctl metadata mpris:artUrl)
|
|
ap="${art_url##*/}"
|
|
|
|
if [[ -n $ap ]]; then
|
|
cfp="$HOME/.cache/ncspot/covers/$ap"
|
|
|
|
# should have a timeout
|
|
counter=0
|
|
until [ -e $cfp ]; do
|
|
sleep 1
|
|
# counter=$((counter + 1))
|
|
# if [ "$counter" -eq 60 ]; then
|
|
# break
|
|
# fi
|
|
done
|
|
MIME_TYPE=$(file -b --mime-type "$cfp")
|
|
SUB_TYPE=$(echo "$MIME_TYPE" | cut -d'/' -f2)
|
|
curr_dir="$HOME/.cache/ncspot"
|
|
nfp="$curr_dir/$ap.$SUB_TYPE"
|
|
cp $cfp $nfp
|
|
|
|
# Extract the subtype (e.g., "jpeg", "plain")
|
|
SUB_TYPE=$(echo "$MIME_TYPE" | cut -d'/' -f2)
|
|
notify-send -a ncspot "$title" "$album\n$artist" --hint=string:image-path:$nfp --icon "/usr/share/icons/Papirus-Dark/24x24/devices/audio-speakers.svg"
|
|
fi
|
|
done
|
|
|