emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Integrating Org with OS X Reminders (and Siri!)
@ 2015-05-28 13:29 Ken Mankoff
  0 siblings, 0 replies; only message in thread
From: Ken Mankoff @ 2015-05-28 13:29 UTC (permalink / raw)
  To: Org Mode

Hi List,

I've written a set of small scripts so that I can use the Reminders.app on my iPhone and easily get that information into Org. This means I can pick up the phone, say "Hey Siri, Remind me about something", and get that info into Org!

Functionality is basic - items show up in Agenda just like MobileOrg items, with a "REFILE" flag set so that I can then refile them. If you mark an item as done in Org, that state is not reflected on your iPhone or in Reminders.app (although this could be possible with a bit of extra coding).

It is a hacked solution with many parts (rem, rem.py, rem.sh, rem.org, and rem.plist), described below:

1) Set up Reminders in iCloud so that Reminders on iPhone and Desktop are synced.

2) Install "rem" utility from: https://github.com/kykim/rem

3) Build and put the binary somewhere and check that "rem ls" lists your reminders

4) Take following "rem.py" and put it somewhere and make sure it runs and prints out all reminders and their details. You probably need to change "~/bin/rem" line near the top to the path to your "rem" binary above.

#!/usr/bin/env python

import subprocess

def rem(args):
    '''Execute the 'rem' command with whatever arguments passed and capture output'''
    cmd = "~/bin/rem " + args + " |perl -p -e 's/[[:^ascii:]]//g'"
    value = subprocess.check_output(cmd, shell=True)
    return value

def get_lists():
    '''Return a list of the list names'''
    r = rem("ls")
    r = r.split("\n")
    r = r[1:-1]  # drop the "Reminders" title and final newline
    r = [rr.strip() for rr in r]
    l = [rr for rr in r if not rr[0].isdigit()]
    return l

def get_num_items(lists):
    '''Return an integer vector with the number of items in each list'''
    n = []
    for l in lists:
        i = rem("ls " + l)
        i = i.split("\n")
        i = i[2:-1]  # drop the "Reminders" title and final newline
        n.append(len(i))
    return n
        
def reminder_item_to_task(list, item, depth=2, TODO=False):
    task = rem("cat " + list + " " + str(item))
    task = task.split("\n")[:-1]

    TODO = "TODO " if TODO else ""

    title = task[0].split(": ")[1:]
    title = ''.join(title)
    title = '*'*depth + " " + TODO + title

    depth += 1
    
    meta = task[2:4]
    meta = [m.replace('\t','') for m in meta]
    meta = [' '*depth + m for m in meta]
    meta = '\n'.join(meta)
    
    notes = task[4:]
    if len(notes) == 0:
        notes = ''
    else:
        notes[0] = notes[0].split(": ")[1]
        notes = [' '*depth + n for n in notes]
        notes = '\n'.join(notes)

    return title + "\n" + meta + "\n" + notes

if __name__ == "__main__":
    lists = get_lists()
    num = get_num_items(lists)
    for l,n in zip(lists,num):
        for i in range(n):
            t = reminder_item_to_task(l, i+1, TODO=True)
            print t


5) Customize the following "rem.sh" script that should run the "rem.py" and produce an Org file. This Org file is tagged REFILE (something I use in my Agenda to help me refile MobilOrg generated items).



#!/usr/bin/env bash

SRC=~/tmp/rem.org
DEST=~/Documents/Org/rem.org

echo "# -*- coding: utf-8; eval: (auto-revert-mode 1); -*-" > ${SRC}
echo "#+FILETAGS: REFILE" >> ${SRC}
/Users/mankoff/bin/rem.py >> ${SRC}

# check if it changed
if ! cmp ${SRC} ${DEST} > /dev/null 2>&1
then
    cp ${SRC} ${DEST}
fi


6) Set up a LaunchAgent plist (here com.kenmankoff.rem2org.plist) so that any reminders are automatically imported into Org. This file goes into ~/Library/LaunchAgents and is also customized for your paths...

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>com.kenmankoff.rem2org</string>
	<key>ProgramArguments</key>
	<array>
	<string>/Users/mankoff/bin/rem.sh</string>
	</array>
	<key>WatchPaths</key>
	<array>
  		<string>/Users/mankoff/Library/Calendars/</string>
	</array>
</dict>
</plist>

7) Load the LaunchAgent with "launchctl load com.kenmankoff.rem2org.plist"

8) Add a section to your Agenda so that "REFILE" tags items show up:

   (tags "REFILE" ((org-agenda-overriding-header "REFILE")))

9) Add an item on your phone, or check one off. Refresh your Agenda. Items should appear/disappear.


Hope someone finds this useful,

  -k.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-05-28 13:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-28 13:29 Integrating Org with OS X Reminders (and Siri!) Ken Mankoff

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).