Update mpris plugin with cover art

This commit is contained in:
Hydroxycarbamide 2022-09-15 00:25:31 +02:00
parent 8d5ee408cf
commit 0ff84042ab
5 changed files with 145 additions and 27 deletions

22
bin/get_mpris_art.sh Executable file
View file

@ -0,0 +1,22 @@
read -d'\n' -ra PLAYERS <<<"$(playerctl -l 2>/dev/null)"
declare -a PAUSED
for player in "${PLAYERS[@]}"; do
[ "$player" = "playerctld" ] && continue;
p_status=$(playerctl -p "$player" status 2>/dev/null)
# if we have one playing, we'll use it and EXIT
if [ "$p_status" = "Playing" ]; then
echo $(playerctl -p $player metadata | grep artUrl | awk '{$1=$2=""; print $0}')
exit 0;
fi
[ "$p_status" = "Paused" ] && PAUSED+=("$player")
done
# if we have a paused, show it otherwise assume there are no players or have all stopped
if [ -n "${PAUSED[0]}" ]; then
echo $(playerctl -p ${PAUSED[0]} metadata | grep artUrl | awk '{$1=$2=""; print $0}')
fi

View file

@ -35,17 +35,17 @@ get_info() {
# if not "icon", display information and return
if [ "$2" != "icon" ]; then
printf "$title"
artist=$(extract_meta artist)
[ -z "$artist" ] && artist=$(extract_meta albumArtist)
if [ -n "$artist" ]; then
album=$(extract_meta album)
[ -n "$album" ] && echo -n "$album"
[ -n "$album" ] && printf "\nfrom $album"
echo -n "$artist"
printf "\nby $artist"
fi
echo "$title"
return 0
fi