From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ken Mankoff Subject: Integrating Org with OS X Reminders (and Siri!) Date: Thu, 28 May 2015 09:29:06 -0400 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yxxs4-000371-FF for emacs-orgmode@gnu.org; Thu, 28 May 2015 09:29:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yxxry-0007Dp-MF for emacs-orgmode@gnu.org; Thu, 28 May 2015 09:29:16 -0400 Received: from mail-qg0-x229.google.com ([2607:f8b0:400d:c04::229]:33169) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yxxry-0007Dg-Hq for emacs-orgmode@gnu.org; Thu, 28 May 2015 09:29:10 -0400 Received: by qgfa63 with SMTP id a63so16266977qgf.0 for ; Thu, 28 May 2015 06:29:09 -0700 (PDT) Received: from parma (c-50-152-65-238.hsd1.pa.comcast.net. [50.152.65.238]) by mx.google.com with ESMTPSA id 104sm1028164qgj.43.2015.05.28.06.29.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 May 2015 06:29:08 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org 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... Label com.kenmankoff.rem2org ProgramArguments /Users/mankoff/bin/rem.sh WatchPaths /Users/mankoff/Library/Calendars/ 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.