Skip to content

Instantly share code, notes, and snippets.

@KeyboardCowboy
Created February 20, 2017 00:14
Show Gist options
  • Save KeyboardCowboy/a575cfa42e11dafa7c8e25ae5117db71 to your computer and use it in GitHub Desktop.
Save KeyboardCowboy/a575cfa42e11dafa7c8e25ae5117db71 to your computer and use it in GitHub Desktop.
Have Your Mac Tell You Inspirational Quotes
# Say a quote every hour on the half hour.
30 * * * * /path/to/quotes.sh
#!/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
"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