From 03307fa78845e033f774a467a92f73d7935e0552 Mon Sep 17 00:00:00 2001 From: cedricAbonnel Date: Mon, 28 Mar 2022 23:30:33 +0200 Subject: [PATCH] MAJ config de run_music_background : volume --- run_music_background | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/run_music_background b/run_music_background index ad157ce..bccd175 100755 --- a/run_music_background +++ b/run_music_background @@ -1,34 +1,37 @@ #!/bin/bash -## Read config file +## Read config file or create/update config_filename=~/.config/$(basename ${0}) -test -f ${config_filename} && . ${config_filename} || config_file_create=1 +test -f ${config_filename} && . ${config_filename} || echo "# Fichier de configuration créé $(date +%c)" | tee ${config_filename} -### Check directory music background -if [[ -z "${path_music_file}+set" ]]; then +### 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_file}+set" ]]; then - path_music_files=${USER} +if [[ -z "${path_music_files+set}" ]]; then + path_music_files=~ + echo "path_music_files=${path_music_files}" | tee -a ${config_filename} 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} +### edit volume +if [[ -z "${volume+set}" ]]; then + volume=0.06 + echo "volume=${volume}" | tee -a ${config_filename} fi ## Init var files=($path_music_files/*) -volume=0.06 ## execute echo Process number $$ echo Path files : $path_music_files echo Number of files in the path : ${#files[@]} -while [ 1 ];do +run_play=0 +while [ ${run_play} -eq 0 ];do file=${files["$[RANDOM % ${#files[@]}]"]} echo Now playing $file - play -v $volume "$file" &> /dev/null + play -S -v $volume "$file" + run_play=$(echo $?) done