scripts/beep: implement locking

This commit is contained in:
Michele Guerini Rocco 2019-09-24 16:58:49 +02:00
parent df4c9f1789
commit 45a38dce0f
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450
2 changed files with 8 additions and 0 deletions

View File

@ -1,4 +1,7 @@
#!/bin/sh #!/bin/sh
lock=/tmp/.beep-lock
test -f $lock && exit 1 || touch $lock
head -c 8 /dev/urandom | \ head -c 8 /dev/urandom | \
hexdump -v -e '/1 "%u\n"' | \ hexdump -v -e '/1 "%u\n"' | \
awk '{ split("0,3,5,6,7,10,12",a,","); \ awk '{ split("0,3,5,6,7,10,12",a,","); \
@ -6,3 +9,4 @@ head -c 8 /dev/urandom | \
printf("%08X\n", 60*sin(450*exp((a[$1 % 8]/12)*log(2))*i)) }' | \ printf("%08X\n", 60*sin(450*exp((a[$1 % 8]/12)*log(2))*i)) }' | \
xxd -r -p | \ xxd -r -p | \
aplay -c 1 -f S32_LE -r 48000 -D plug:default aplay -c 1 -f S32_LE -r 48000 -D plug:default
rm -f $lock

View File

@ -1,4 +1,7 @@
#!/bin/sh #!/bin/sh
lock=/tmp/.beep-lock
test -f $lock && exit 1 || touch $lock
head -c 4 /dev/urandom | \ head -c 4 /dev/urandom | \
hexdump -v -e '/1 "%u\n"' | \ hexdump -v -e '/1 "%u\n"' | \
awk '{ split("0,3,5,6,7,10,12",a,","); \ awk '{ split("0,3,5,6,7,10,12",a,","); \
@ -6,3 +9,4 @@ head -c 4 /dev/urandom | \
printf("%08X\n", 40*sin(450*exp((a[$1 % 8]/12)*log(2))*i)) }' | \ printf("%08X\n", 40*sin(450*exp((a[$1 % 8]/12)*log(2))*i)) }' | \
xxd -r -p | \ xxd -r -p | \
aplay -c 2 -f S16_LE -r 48000 -Dplug:hdmi1 aplay -c 2 -f S16_LE -r 48000 -Dplug:hdmi1
rm -f $lock