Last active
February 24, 2019 00:46
-
-
Save uxjw/c144b0e9ace489ede6b722ad1850c55d to your computer and use it in GitHub Desktop.
Hourly announcement with quiet hours
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 | |
# Announce the current hour | |
# | |
# Use cron to schedule this on the hour: | |
# 0 * * * * /path/to/script/chime.sh | |
# | |
# Change the voice used in System Preferences | |
# under Accessibility > Speech | |
# Wake up the text-to-speech engine, which sometimes | |
# misses the first part of text and just says "o'clock" | |
say " " | |
sleep 2 | |
# 24-hour time for if statements | |
HOUR=$(date +%k) | |
# Silence from 1am through 9am | |
if [ $HOUR -gt 9 ] | |
then | |
# If past noon, use 12-hour format | |
# AM/PM should be obvious | |
if [ $HOUR -gt 12 ] | |
then | |
HOUR=$(date +%l) | |
fi | |
# Announce hour | |
say "Its " $HOUR " o'clock" | |
else | |
# Instead of hour 0, say midnight | |
if [ $HOUR -eq 0 ] | |
then | |
say "Its midnight" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment