scripts-bash/run_music_background

38 lines
1.0 KiB
Plaintext
Raw Normal View History

#!/bin/bash
## 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}
### edit directory path music background
if [[ -z "${path_music_files+set}" ]]; then
path_music_files=$(xdg-user-dir MUSIC)
echo "path_music_files=${path_music_files}" | tee -a ${config_filename}
fi
if [[ -z "${path_music_files+set}" ]]; then
path_music_files=~
echo "path_music_files=${path_music_files}" | tee -a ${config_filename}
fi
### edit volume
if [[ -z "${volume+set}" ]]; then
volume=0.06
echo "volume=${volume}" | tee -a ${config_filename}
fi
2022-03-28 18:51:39 +02:00
## Init var
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
file=${files["$[RANDOM % ${#files[@]}]"]}
echo Now playing $file
play -S -v $volume "$file"
run_play=$(echo $?)
done