Plaintext task list from OmniFocus with AppleScript

I live in OmniFocus most of the day. I have lots of perspectives set up to help me parse my various responsibilities (see my previous post, "How I Use OmniFocus," for more details); in particular, I have one perspective called "Global Tasks" (View Mode: Context, Filter: Active, Grouping: Ungrouped, Sorting: Due, Action Filter: Next Action) that essentially gives me a list, ordered by dueness, of what I should be doing right now.

It helps me focus to have that list of tasks constantly in front of my eyes. This is counterbalanced by my desire to save screen real estate for the assorted terminal windows and browsers I need up to do my job; OmniFocus takes up valuable real estate. So I set about writing a quick script to pull tasks from OmniFocus, format them, and return them as plain text, which I could embed on my desktop with GeekTool.

set taskList to ""
tell application "OmniFocus"
tell the default document to tell the front document window
set perspective name to "Global Tasks"
set oTrees to trees of content
set n to count of oTrees
repeat with i from 1 to n
set oTask to value of (item i of oTrees)
set taskTitle to name of oTask
set projTitle to name of containing project of oTask
set taskList to taskList & taskTitle &
" (" & projTitle & ")\n"
end repeat
end tell
end tell
return taskList

I saved that as ~/src/omnifocus_tasks.scpt and added a Command item to GeekTool that ran osascript /Users/ian/src/omnifocus_tasks.scpt every minute. The result was exactly what I wanted:

Now, even if I hide OmniFocus to make room for something else, I can't forget to check for my next tasks and keep everything up to date.


Post a Comment