Skip to content

Instantly share code, notes, and snippets.

@critiqjo
Created October 18, 2016 17:22
Show Gist options
  • Save critiqjo/48492e07565f7dad0566dd807d197a27 to your computer and use it in GitHub Desktop.
Save critiqjo/48492e07565f7dad0566dd807d197a27 to your computer and use it in GitHub Desktop.
A dumb timer-notifier!
#!/bin/bash
# Alerts a message using `notify-send` at the time specified.
# The time specified should be understood by `date -d` option.
set -e
[ -z "$2" ] && {
echo "Usage: $0 <time-desc> <message>"
echo
echo "Examples:"
echo "\$ $0 +30mins 'Hello, World!'"
echo "\$ $0 22:30 'Good night!'"
exit
}
future_secs=$(date -d "$1" +%s)
now_secs=$(date +%s)
secs_till_future=$((future_secs - now_secs))
echo "Sleeping for $((secs_till_future/60)) minutes $((secs_till_future%60)) seconds"
sleep $secs_till_future && notify-send --urgency=critical "$2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment