Created
October 9, 2017 13:30
-
-
Save chreke/03c2b326e978e92931eeef267c054135 to your computer and use it in GitHub Desktop.
Add Reminder item from command line
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
#!/usr/bin/python | |
import datetime | |
import re | |
import subprocess | |
title = raw_input('What do you want to be reminded about? ') | |
assert title, 'Title cannot be blank' | |
when = raw_input('When do you want to be reminded? ') | |
regex = r'(?P<date>\d{4}-\d{2}-\d{2})? ?'\ | |
r'(?P<time>\d{2}:\d{2})?' | |
match = re.match(regex, when) | |
date = match.group('date') or str(datetime.datetime.now().date()) | |
time = match.group('time') or '12:00' | |
SCRIPT = ''' | |
osascript - "{title}" "{date} {time}" <<END | |
on run argv | |
set stringedAll to date (item 2 of argv) | |
tell application "Reminders" | |
make new reminder with properties {{name:item 1 of argv, due date:stringedAll}} | |
end tell | |
end run | |
END | |
'''.format(title=title, date=date, time=time) | |
subprocess.call(SCRIPT, shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment