Created
March 17, 2017 15:46
-
-
Save kylemarsh/aed3ce045ae38115390ec39810169396 to your computer and use it in GitHub Desktop.
Variable-period notifier for OSX
This file contains hidden or 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/sh | |
# Variable-period notifier for OSX | |
# Requires the following (available via homebrew): | |
# terminal-notifier (https://github.com/julienXX/terminal-notifier) | |
# reattach-to-user-namespace (https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard) | |
# See below for information about reattach-to-user-namespace (necessary to connect to notifications via `at`): | |
# https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard#mac-os-x-pasteboard-access-under-tmux-and-screen | |
########## | |
# Log all output to file for debugging | |
#exec 1<&1- | |
#exec 2<&1- | |
#exec 1<>~/logflowers.log | |
#exec 2>&1 | |
######### | |
SCRIPT='bin/reminder.sh' | |
NEXT=`awk 'BEGIN{srand(); printf("%d\n", rand()*60+30)}'` # 30 + (0-60) | |
TITLE="Remember to do the thing!" | |
MESSAGE="Next in $NEXT days" | |
RESULT=`reattach-to-user-namespace terminal-notifier \ | |
-message "$MESSAGE" \ | |
-title "$TITLE" \ | |
-sound "Purr" \ | |
-open "http://www.cnn.com/" \ | |
-actions "Tomorrow" \ | |
-timeout 6` # Customize as you like | |
case $RESULT in | |
'@CONTENTCLICKED') | |
# reschedule for 9am $NEXT days from now if clicked | |
at -f $SCRIPT 09:00 +$NEXT days | |
;; | |
'Tomorrow') | |
# reschedule for 9am tomorrow if "Tomorrow" | |
# don't do +1 days because it's already past 9am | |
at -f $SCRIPT 09:00 | |
;; | |
'@TIMEOUT') | |
# reschedule for a few min from now if not clicked after 30s | |
at -f $SCRIPT now +5 minutes | |
;; | |
*) | |
ac -f $SCRIPT now +5 minutes | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment