Created
February 20, 2017 00:14
-
-
Save KeyboardCowboy/a575cfa42e11dafa7c8e25ae5117db71 to your computer and use it in GitHub Desktop.
Have Your Mac Tell You Inspirational Quotes
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
# Say a quote every hour on the half hour. | |
30 * * * * /path/to/quotes.sh |
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
#!/usr/bin/env bash | |
# | |
# Say a Quote | |
# Have your Mac say something inspirational. | |
# Add necessary commands to the PATH. You may need to install GNU | |
# coreutils for gsort to work. | |
PATH="/usr/local/bin:$PATH" | |
# Set variables. | |
DEFAULT_VOICE="Samantha" | |
FILE="/path/to/quotes.txt" | |
SPEED=180 # Words/minute | |
# Get a random quote. | |
LINE=`gsort -R $FILE | head -n 1` | |
# Separate the Voice and Quote from the line. | |
VOICE=`echo $LINE | cut -d '|' -f1` | |
QUOTE=`echo $LINE | cut -d '|' -f2` | |
# If a voice was not specified, both values will be the same, so use the | |
# default voice. | |
if [[ "$VOICE" == "$QUOTE" ]]; then | |
VOICE=$DEFAULT_VOICE | |
fi | |
# Say the quote. | |
say -r $SPEED -v $VOICE $QUOTE |
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
"Do or do not. There is no try." - Yoda | |
Alex|"If you want to make an apple pie from scratch, you must first create the universe." - Carl Sagan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment