mplayerd-getinfo (1583B)
1 #!/bin/bash 2 3 # notify-send -i ~/img/fonds\ d\'écran/3153_small.jpg "Antony Raijekov - Deep blue (2005)" "blablabla" 4 # zenity --notification --window-icon=/usr/share/icons/gnome/scalable/mimetypes/audio-x-generic.svg --text "Antony Raijekov - Moment of Green (2005)" 5 6 source "$(dirname "$0")/config" 7 8 q="'" 9 10 old_titre="" 11 old_artiste="" 12 old_album="" 13 14 cat "$MP_OUTPUT" \ 15 | while read ligne; do 16 # Détection de la fin de fichier (voir commentaire dans mplayerd-play. 17 if [ "$ligne" == "Playing /dev/null." ]; then 18 echo "EOF" 19 fi 20 # TODO : utiliser grep n'est pas du tout efficace ! 21 if grep -q "^[a-zA-Z_][a-zA-Z0-9_]*='"<<<"$ligne"; then 22 modif=0 23 cle="${ligne%%=$q*}" 24 valeur="${ligne#*=$q}" 25 valeur="${valeur%$q}" 26 case "$cle" in 27 ANS_META_TITLE) 28 old_titre="$titre" 29 titre="$valeur" 30 if [ "$titre" != "$old_titre" ]; then 31 modif=1 32 echo "TITRE = $titre" 33 fi 34 ;; 35 ANS_META_ARTIST) 36 old_artiste="$artiste" 37 artiste="$valeur" 38 if [ "$artiste" != "$old_artiste" ]; then 39 modif=1 40 echo "ARTISTE = $artiste" 41 fi 42 ;; 43 ANS_META_ALBUM) 44 old_album="$album" 45 album="$valeur" 46 if [ "$album" != "$old_album" ]; then 47 modif=1 48 echo "ALBUM = $album" 49 fi 50 ;; 51 esac 52 if [ "$modif" != "0" ]; then 53 notify-send -i ~/img/fonds\ d\'écran/3153_small.jpg "$artiste - $titre" "Album: $album" 54 fi 55 else 56 # TODO : peut-être envoyer seulement quand il affiche "now playing..." 57 ( 58 echo "get_meta_title" > "$MP_CONTROL" 59 echo "get_meta_artist" > "$MP_CONTROL" 60 echo "get_meta_album" > "$MP_CONTROL" 61 ) & 62 fi 63 done