Liste de lecture aleatoire infinie sur Mpd


 

Utilité : Fais tourner aléatoirement les morceaux de la bibliioteque MPD et efface les morceaux deja lus. En dessous de 500 morceaux dans la playlist, on recommence.

Dependances : mpc

Script 1  : A copier sous /usr/ocal/bin/mpd2

 #!/bin/bash

if [ -e /usr/local/bin/List_Mpd ] ; then cp /usr/local/bin/List_Mpd /dev/shm/List_Mpd
else mpc listall > /dev/shm/List_Mpd ; fi

while true ; do
        while [ `mpc playlist | wc -l` -lt 10 ] || [ "`mpc playlist | tail -1`" == "`mpc current`" ]
                do
                        Random="`shuf -n 1 /dev/shm/List_Mpd`" &&  mpc add "$Random"
                        grep -v "$Random" /dev/shm/List_Mpd > /dev/shm/Temp && mv /dev/shm/Temp /dev/shm/List_Mpd
                        if [ `cat /dev/shm/List_Mpd | wc -l` -lt 500 ] ; then mpc listall > /dev/shm/List_Mpd ; fi
        done
mpc current --wait
done

 

 

Script 2 : A copier sous /usr/ocal/bin/stopmpd2 ( je sais je suis un flemmard !)

#!/bin/bash

cp /dev/shm/List_Mpd  /usr/local/bin/List_Mpd
 

 

Script 3 : A copier sous /etc/systemd/system/mpd2.service

[Unit]
Description=ashuffle
Requires=mpd.service
After=mpd.service

[Service]
ExecStart=/usr/local/bin/mpd2
ExecStop=/bin/bash /usr/local/bin/stopmpd2
Type=simple


[Install]
WantedBy=default.target



 

 


Plan du site Version imprimable Envoyer un mailLivre d'or


Flux Rss