2021-12-12 11:02:26 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-03-28 19:56:57 +02:00
|
|
|
## Read config file
|
|
|
|
config_filename=~/.config/$(basename ${0})
|
|
|
|
test -f ${config_filename} && . ${config_filename} || config_file_create=1
|
|
|
|
|
|
|
|
### Check directory music background
|
|
|
|
if [[ -z "${path_music_file}+set" ]]; then
|
|
|
|
path_music_files=$(xdg-user-dir MUSIC)
|
|
|
|
fi
|
|
|
|
if [[ -z "${path_music_file}+set" ]]; then
|
|
|
|
path_music_files=${USER}
|
|
|
|
fi
|
|
|
|
|
|
|
|
## Write config file
|
|
|
|
if [ config_file_create -eq 1 ]; then
|
|
|
|
echo "# Fichier de configuration créé $(date +%c)" | tee ${config_filename}
|
|
|
|
echo "path_music_files=${path_music_files}" | tee ${config_filename}
|
|
|
|
fi
|
2022-03-28 18:51:39 +02:00
|
|
|
|
2022-03-28 19:56:57 +02:00
|
|
|
## Init var
|
|
|
|
files=($path_music_files/*)
|
|
|
|
volume=0.06
|
2021-12-12 11:02:26 +01:00
|
|
|
|
2022-03-28 19:56:57 +02:00
|
|
|
## execute
|
2021-12-12 11:02:26 +01:00
|
|
|
echo Process number $$
|
2022-03-28 19:56:57 +02:00
|
|
|
echo Path files : $path_music_files
|
2021-12-12 11:02:26 +01:00
|
|
|
echo Number of files in the path : ${#files[@]}
|
|
|
|
|
|
|
|
while [ 1 ];do
|
|
|
|
file=${files["$[RANDOM % ${#files[@]}]"]}
|
|
|
|
echo Now playing $file
|
|
|
|
play -v $volume "$file" &> /dev/null
|
|
|
|
done
|