python + growl + remember the milk = launchbar task management
Intro
Once I could add tasks to my RTM account through LaunchBar I wanted a way to quickly pull up a view of what tasks were due today through LaunchBar. The Growl library provides a nice way of doing this.
The overview is as follows: Activate LaunchBar and type due. This due is installed as a search shortcut and you can search for today, tomorrow, or all (abbreviations are also easy). The search shortcut runs the python script that searches your tasks on Remember the Milk. For each task it finds it puts up a sticky Growl notification so you get a nice list of tasks on your screen. You could easily customize the script to put all the tasks in a single notification but I like them separate.
Since the Growl module registers this script as an application you can also use the Growl Preference Pane to customize the look and feel or even the location of your notifications. You can also customize whether you want the notifications to be sticky or not.
The Code
Here is the code for doing all of this. It makes use of the filter parameter on getList.
#!/usr/bin/env python
from rtm import *
import sys
import Growl
def sendNotify(ts):
if type(ts.task) == list:
for j in range(len(ts.task)):
notifier.notify("today","Task Due: "+ts.task[j].due[:10],ts.name,sticky=True)
else:
notifier.notify("today","Task Due: "+ts.task.due[:10],ts.name,sticky=True)
if len(sys.argv) == 2:
command = sys.argv[1]
else:
command = "today"
apiKey = "get your own"
secret = "this too"
token = "You will create this"
name = "RTMDue"
notifications = ["today","tomorrow"]
notifier = Growl.GrowlNotifier(name,notifications)
notifier.register()
if command[:3] == "tod" or command == '':
cutoff = 'today'
elif command[:3] == "tom":
cutoff = 'tomorrow'
else:
cutoff = None
rtm = createRTM(apiKey, secret, token)
if cutoff:
filterString = 'status:incomplete and (due:%s or dueBefore:%s)'%(cutoff,cutoff)
else:
filterString = 'status:incomplete'
theTasks = rtm.tasks.getList(filter=filterString)
if type(theTasks.tasks.list) == list:
for i in range(len(theTasks.tasks.list)):
if type(theTasks.tasks.list[i].taskseries) == list:
for j in range(len(theTasks.tasks.list[i].taskseries)):
ts = theTasks.tasks.list[i].taskseries[j]
sendNotify(ts)
else:
ts = theTasks.tasks.list[i].taskseries
sendNotify(ts)
else:
if type(theTasks.tasks.list.taskseries) == list:
for i in range(len(theTasks.tasks.list.taskseries)):
ts = theTasks.tasks.list.taskseries[i]
sendNotify(ts)
else:
ts = theTasks.tasks.list.taskseries
sendNotify(ts)
Next Steps
It would be great if I can figure out a way to have the Growl notification box call a script to mark the task as done. Feel free to leave comments or suggestions or improvements in the comments.