Created
January 8, 2020 19:47
-
-
Save JDiPierro/b300ae78f4d3ead672bc13b9074f804d to your computer and use it in GitHub Desktop.
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 | |
# Takes a 24-hour time as the first argument and displays the second argument as a Mac dialog at that time. | |
# Usage: | |
# $ timebox 15:00 "Refresh the dashboard" | |
TARGET="${1}" | |
if [[ -z "${TARGET}" ]] ; then | |
echo "You must pass a time as the first argument" >&2 | |
exit 1 | |
fi | |
MSG="${2}" | |
if [[ -z "${MSG}" ]] ; then | |
echo "You must pass message as the second argument" >&2 | |
exit 1 | |
fi | |
current_epoch=$(gdate +%s) | |
target_epoch=$(gdate -d "today ${TARGET}" +%s) | |
sleep_seconds=$(( $target_epoch - $current_epoch )) | |
echo "Message will be displayed after ${sleep_seconds} seconds." | |
( | |
sleep ${sleep_seconds}; | |
osascript -e "tell app \"System Events\" to display dialog \"$MSG\"" >/dev/null | |
) & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment