Last active
December 9, 2018 07:25
-
-
Save jbwhaley/4deac45790fa339b537a to your computer and use it in GitHub Desktop.
QuickReminder
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
# 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.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: