Created
June 28, 2019 20:53
-
-
Save nbhasker/730f4f92c2bd82b322fb097bd8b31723 to your computer and use it in GitHub Desktop.
Record grandfather clock strikes every hour on Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Record grandfather clock strikes every hour | |
# Narjala Bhasker | |
# 6/13/2019 | |
TARGET_TIME_SECS=$((59*60)) | |
while true | |
do | |
# Sleep until 59 minutes past the hour | |
CURRENT_TIME_SECS=$(($(date +%-M) * 60 + $(date +%-S))) | |
SLEEP_TIME_SECS=$(($TARGET_TIME_SECS - $CURRENT_TIME_SECS)) | |
if [[ $SLEEP_TIME_SECS -le 0 ]] | |
then | |
SLEEP_TIME_SECS=$((SLEEP_TIME_SECS + 3600)) | |
fi | |
echo "Target Time: " $TARGET_TIME_SECS | |
echo "Current Time: " $CURRENT_TIME_SECS | |
echo "Sleep Time: " $SLEEP_TIME_SECS | |
sleep $SLEEP_TIME_SECS | |
FILE_NAME=$(date "+%Y.%m.%d-%H.%M.%S")".wav" | |
# Record 120 seconds of audio and save into appropriately named file | |
arecord -f CD -d 120 $FILE_NAME | |
echo $FILE_NAME " written" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment