1
0
Fork 0
Scripts/Perso/bootSound.sh
trotFunky b6bcec6d88 bootSound: Remove usage of /dev/urandom
The bootSound script started to hang on strings /dev/urandom,
so replace it with a cleaner random number generation.

24134 could be used for bash, but this would make the script
less generic, as it is not available in POSIX.

Use awk random() from a suggestion from ShellCheck.

Remove the code that was there to control the parsing from
/dev/urandom.

Other fixes :
 - Use wc rather than grep to count the files
 - Use a subshell for proper directory handling
2023-11-20 11:40:25 +01:00

10 lines
226 B
Bash
Executable file

#! /bin/sh
(
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"_*
)
exit 0