Scotch Linux arbre1 fly maison ScotchLinux... arbre

Remarque: Ce script permet, en ligne de commande simple, de lancer un cd audio (cmd start) et de le retirer pour retourner à la playlist souhaitée (cmd stop playlist). Il peut largment être complété avec l'utilisation libcdio-utils par exemple.


#!/bin/bash
function help(){
echo "usage: cdda-xmms2.sh:"
echo "Arguments:"
echo "play:launch and play audio cd."
echo "stop playlist:stop audio cd clear and remove playlist. Go on first song of playlist."
exit
}
function badarg(){
echo "$1"
exit
}
function cdrom_playlist_clear(){
local PLAYLIST="$(nyxmms2 playlist list | grep cdrom)"
test -z "$PLAYLIST" && return 1
test -z "$(echo "$PLAYLIST" | grep -e "^\* cdrom")" && nyxmms2 playlist switch cdrom
test -z "$(nyxmms2 list | grep -E ".*: 0(:[0]{2}){2}")" && nyxmms2 clear
return 0;
}
test -z "$(pidof xmms2d)" && xmms2-launcher
case $1 in
play)
cdrom_playlist_clear
#$? est la valeur de retour de la fonction cdrom_playlist_clear
if [ $? -eq 1 ]; then
for i in "create" "switch"; do
nyxmms2 playlist "$i" cdrom
done
fi;
nyxmms2 add -P cdda://
test -z "$(nyxmms2 status | grep -E "^Playing:.*")" && nyxmms2 play
;;
stop)
test -z "$2" && badarg "Too few arguments."
test -z "$(nyxmms2 playlist list | grep "$2")" && badarg "No playlist: '$2'"
cdrom_playlist_clear
test $? -eq 1 && exit
nyxmms2 playlist switch "$2"
;;
help)
help
;;
*)
test -z "$1" && badarg "Too few arguments."
badarg "bad argument: '$1'"
;;
esac
nyxmms2 jump 1
test $1 = "stop" && nyxmms2 playlist remove cdrom