Skip to content

Instantly share code, notes, and snippets.

@nshenry03
Last active February 13, 2023 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nshenry03/87377674714b313bd101e3907ecaa619 to your computer and use it in GitHub Desktop.
Save nshenry03/87377674714b313bd101e3907ecaa619 to your computer and use it in GitHub Desktop.
Cronjob to help keep track of water
0 9-19 * * 1-5 ${HOME}/.local/bin/drink-water.sh
#!/bin/bash -
#===============================================================================
#
# FILE: drink-water.sh
#
# USAGE: ./drink-water.sh
#
# DESCRIPTION: Make sure to drink enough water
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Nick Henry (NSH), hnicholas@vmware.com
# ORGANIZATION: VMware, Inc.
# CREATED: 2023-02-08 17:48:57
# REVISION: ---
#===============================================================================
set -o nounset # treat unset variables as errors
#===============================================================================
# GLOBAL DECLARATIONS
#===============================================================================
declare -rx SCRIPT=${0##*/} # the name of this script
declare -rx TIMEOUT=300 # seconds alert is shown
declare -rx OZ_WATER=$(( 32 * ( $(date +%H) - 8 ) ))
#===============================================================================
# SANITY CHECKS
#===============================================================================
if [ -z "$BASH" ] ; then
printf "$SCRIPT:$LINENO: run this script with the BASH shell\n" >&2
exit 192
fi
#===============================================================================
# MAIN SCRIPT
#===============================================================================
/opt/homebrew/bin/alerter \
-title Water \
-group water \
-message "By now, you should have drinken ${OZ_WATER}oz of water" \
-timeout ${TIMEOUT}
> /dev/null 2>&1
#===============================================================================
# STATISTICS / CLEANUP
#===============================================================================
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment