monitor.sh
howtophil |
PRO |
03/06/24 03:54:52 AM UTC (Edited) |
0 ⭐ |
1248 👁️ |
Never ⏰ |
[BASH, notify, INotify]
#!/bin/sh
#---------------------------------
# This is a sister-script for the
# scanner-record.sh script.
# https://pastebin.com/8vygm3wM
# It will watch for new recordings
# and by default beep then play
# the recording.
# You can change that to make it
# email the recordings to you,
# upload them someplace else,
# or whatever else you want to do.
#---------------------------------
# Phillip J Rhoades (HowToPhil)
# 2023-03-05
#---------------------------------
#---------------------------------
# Define variable(s) to control
# how script functions
#---------------------------------
THEDIR="./record"
#---------------------------------
# Time for the script to start
# doing things!
#---------------------------------
echo "Begin monitoring the folder for new recordings!"
#---------------------------------
# Wait for a new file to appear
# in the directory.
#---------------------------------
inotifywait -q -m -r -e create --format '%w%f' "${THEDIR}" | while read THEFILE
do
#---------------------------------
# Do this when a file is created
#---------------------------------
# Wait for the file to close so
# we can play it, move it, email
# it, or do whatever else we
# want.
#---------------------------------
inotifywait -q -e close_write "$THEFILE"
echo "New recording: $THEFILE"
#---------------------------------
# This will beep at us, in case
# we don't want the file to play
# but we want to know a file has
# been created or we want a tone
# to get oru attention before the
# recording plays.
#---------------------------------
play -V1 -n -c1 synth .3 sine 200
#---------------------------------
# Play the file so we can hear
# what just came into the scanner.
#---------------------------------
play "$THEFILE"
echo
echo "->Monitoring the folder for the next new recording!"
done
Comments