MAJ run_music_background : liste de fichiers déduite des fichiers lus
This commit is contained in:
parent
03307fa788
commit
181d440ba8
|
@ -1,5 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Intercepte le ^C
|
||||
#trap 'exit 130' INT
|
||||
|
||||
## Read config file or create/update
|
||||
config_filename=~/.config/$(basename ${0})
|
||||
test -f ${config_filename} && . ${config_filename} || echo "# Fichier de configuration créé $(date +%c)" | tee ${config_filename}
|
||||
|
@ -24,14 +27,37 @@ fi
|
|||
files=($path_music_files/*)
|
||||
|
||||
## execute
|
||||
|
||||
echo Process number $$
|
||||
echo Path files : $path_music_files
|
||||
echo Number of files in the path : ${#files[@]}
|
||||
|
||||
run_play=0
|
||||
while [ ${run_play} -eq 0 ];do
|
||||
clear
|
||||
file=${files["$[RANDOM % ${#files[@]}]"]}
|
||||
echo Now playing $file
|
||||
|
||||
# suppresion du fichier en cours de lecture
|
||||
new_files=()
|
||||
for file_keep in "${files[@]}"; do
|
||||
[[ "$file_keep" != "$file" ]] && new_files+=("$file_keep")
|
||||
done
|
||||
files=("${new_files[@]}")
|
||||
unset new_files
|
||||
|
||||
# Nombre d'éléments dans le tableau
|
||||
elements_in_files=${#files[@]}
|
||||
|
||||
echo -e "\n => Now playing $file"
|
||||
echo -e "\n => ${elements_in_files} files left"
|
||||
|
||||
play -S -v $volume "$file"
|
||||
run_play=$(echo $?)
|
||||
|
||||
if [ ${elements_in_files} -eq 0 ]; then
|
||||
run_play=2
|
||||
fi
|
||||
|
||||
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in New Issue