Wikia

Music Player Daemon Community Wiki

Hack:mpd lyric.sh

525pages on
this wiki
Talk0
 #!/bin/bash
 export prog=less
 dir=/home/music/lyrics
 mkdir -p $dir
 cd $dir
 waitLyric () {
       [ "$(mpc|wc -l)" -lt 3 ] && return 0
       while mpc | head -1 | grep "$1" > /dev/null;
       do
               sleep 1;
       done
       kill $(ps -ef | grep "$2" | grep "$1" | sed "s/[^ ]\+ \+\([0-9]\+\).*/\1/")
 }
 
 while sleep 1;
 do
       clear
       out=$(mpc)
       [ "$(echo "$out"|wc -l)" -lt 3 ] && continue;
       title=$(echo "$out" | head -1)
 
       if [ -f "$title" ]; then
               waitLyric "$title" "$prog" &
               $prog "$(echo "$title" | head -1)"
               clear
       else
               read -p "No lyrics found... create? (y/n)" answer
               if [ "$answer" = "y" ];
               then
                       ${EDITOR:-vi} "$title"
               else
                       while mpc | head -1 | grep "$title" > /dev/null;
                       do
                               sleep 1;
                       done
               fi
       fi
 done

Around Wikia's network

Random Wiki