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.
 
 
dotfiles/ncspot/playerctl_notifier.sh

27 lines
1.0 KiB

killall -q playerctl
# delete all the copied image files first
find "$HOME/.cache/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"
until [ -e $cfp ]; do
sleep 1
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