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.
June 8, 2009 at 1:17 AM
After culling a number of useless GeekTool scripts I think this one is here to stay.
Great perspective too. I've never mastered perspectives—perhaps this will help.
Thanks for the posting this!
June 21, 2009 at 10:55 AM
Thanks for posting the script. I am getting the following error when I run it:
"OmniFocus got an error: Can’t get containing project of context id "bgbnl0CNmbN" of document id "b7vFh5pXF0-"."
September 5, 2009 at 10:52 AM
I get a simmilar error as Julia
October 10, 2009 at 6:46 AM
Doesn't work for me either I'm afraid :(
OmniFocus got an error: Can’t get name of value of tree 1 of content of document window id -1 of document id \"m7Mq41yPpmz\"." number -1728 from name of value of tree 1 of content of document window id -1 of document id "m7Mq41yPpmz"
January 8, 2010 at 9:14 AM
I had the same problem and setting the grouping of tasks to "ungrouped" did the trick
best regards
ray
April 24, 2012 at 11:38 AM
I have no idea what Fukyhead's comment means. Is there a way to fix this script?