Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
QuickReminder
# QuickReminder 3.0.2 - see: http://jarrodwhaley.com/other-projects/geekery/
import sys
import urllib.request, urllib.parse, urllib.error
import notification
import console
import webbrowser
# Get arguments, if any
numArgs = len(sys.argv)
# Set Drafts URL
url = 'drafts4://x-callback-url/create?text=' + ''
# Convert minutes to integer, strip commas if present
def intconv(arg):
arg = arg.replace(",", "")
return int(arg) * 60
# Routes and processes input, either directly from prompts
# or from Drafts.
if numArgs == 1:
text = console.input_alert('Remind you to...')
digit = console.input_alert('In how many minutes?')
interval = intconv(digit)
url = ''
elif numArgs > 1 and (sys.argv[2]) == '':
digit = console.input_alert('In how many minutes?')
elif numArgs == 3:
text = sys.argv[1]
digit = sys.argv[2]
interval = intconv(digit)
else:
console.alert('Failed.')
# Confirm before scheduling
console.alert('Schedule?', 'Alert in' + ' ' + digit + ' ' +
'minutes?', 'Schedule')
# Schedule
notification.schedule(text, interval, 'default')
# Send back to Drafts if input sent from there.
# Show confirmation HUD if not.
if len(url) > 1:
webbrowser.open(url)
notification.schedule('Scheduled.', 0.5, 'default')
else:
console.hud_alert('Scheduled.')
Owner

jbwhaley commented May 2, 2013

Overview

This is a Pythonista script which sends the user a reminder in the form of an iOS notification. It receives input from a Drafts.app URL action (pythonista://QuickReminder?action=run&argv=[[title]]&argv=[[body]]), in which the first line contains a textual reminder, and in which the body of the draft contains the number of minutes until the reminder is fired, e.g.:

Reminder text here
1

Notes:

  • Version 3.0:
    • Can now be run from within Pythonista
    • More clearly commented
  • Version 2.2:
    • Removed sound
  • Version 2.1:
    • Much better error handling
    • Usability improvements
  • Version 2.0:
    • Added scheduling confirmation / cancellation
    • Return to Drafts upon scheduling
  • Version 1.1.3: small change to "success" alert.
  • Version 1.1.2: now strips commas from the time interval.
  • Version 1.1.1: clarified language on "success" alert.
  • Version 1.1: adds audio feedback upon the successful scheduling of a reminder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment