diff --git a/Perso/bootSound.sh b/Perso/bootSound.sh index 9c14a2d..7a6b156 100755 --- a/Perso/bootSound.sh +++ b/Perso/bootSound.sh @@ -1,16 +1,10 @@ #! /bin/sh -cd /home/trotfunky/Documents/Sounds/Startup/ -qty=$(ls | grep -c "" ) +( + cd /home/trotfunky/Documents/Sounds/Startup/ || exit 255 + qty=$(ls | wc -l ) + + file_id=$(awk "BEGIN { srand(); print int(rand()*$qty) }" /dev/null) + mplayer -nogui -softvol -ao alsa,pulse "$file_id"_* +) -if [ $qty -lt 10 ]; then - maxBit=1 - diGrep=[[:digit:]] -elif [ $qty -lt 100]; then - maxBit=2 - diGrep=[[:digit:]][[:digit:]] -fi - -mplayer -nogui -softvol -ao alsa,pulse $(expr $(strings /dev/urandom | cut -b 1-$maxBit | grep $diGrep -m 1 ) % $qty )* & -cd - - -exit 0 \ No newline at end of file +exit 0