2021-12-12 11:02:26 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-03-28 23:30:33 +02:00
|
|
|
## Read config file or create/update
|
2022-03-28 19:56:57 +02:00
|
|
|
config_filename=~/.config/$(basename ${0})
|
2022-03-28 23:30:33 +02:00
|
|
|
test -f ${config_filename} && . ${config_filename} || echo "# Fichier de configuration créé $(date +%c)" | tee ${config_filename}
|
2022-03-28 19:56:57 +02:00
|
|
|
|
2022-03-28 23:30:33 +02:00
|
|
|
### edit directory path music background
|
|
|
|
if [[ -z "${path_music_files+set}" ]]; then
|
2022-03-28 19:56:57 +02:00
|
|
|
path_music_files=$(xdg-user-dir MUSIC)
|
2022-03-28 23:30:33 +02:00
|
|
|
echo "path_music_files=${path_music_files}" | tee -a ${config_filename}
|
2022-03-28 19:56:57 +02:00
|
|
|
fi
|
2022-03-28 23:30:33 +02:00
|
|
|
if [[ -z "${path_music_files+set}" ]]; then
|
|
|
|
path_music_files=~
|
|
|
|
echo "path_music_files=${path_music_files}" | tee -a ${config_filename}
|
2022-03-28 19:56:57 +02:00
|
|
|
fi
|
|
|
|
|
2022-03-28 23:30:33 +02:00
|
|
|
### edit volume
|
|
|
|
if [[ -z "${volume+set}" ]]; then
|
|
|
|
volume=0.06
|
|
|
|
echo "volume=${volume}" | tee -a ${config_filename}
|
2022-03-28 19:56:57 +02:00
|
|
|
fi
|
2022-03-28 18:51:39 +02:00
|
|
|
|
2022-03-28 19:56:57 +02:00
|
|
|
## Init var
|
|
|
|
files=($path_music_files/*)
|
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[@]}
|
|
|
|
|
2022-03-28 23:30:33 +02:00
|
|
|
run_play=0
|
|
|
|
while [ ${run_play} -eq 0 ];do
|
2021-12-12 11:02:26 +01:00
|
|
|
file=${files["$[RANDOM % ${#files[@]}]"]}
|
|
|
|
echo Now playing $file
|
2022-03-28 23:30:33 +02:00
|
|
|
play -S -v $volume "$file"
|
|
|
|
run_play=$(echo $?)
|
2021-12-12 11:02:26 +01:00
|
|
|
done
|