Created
October 18, 2016 17:22
-
-
Save critiqjo/48492e07565f7dad0566dd807d197a27 to your computer and use it in GitHub Desktop.
A dumb timer-notifier!
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
#!/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