Skip to content

Instantly share code, notes, and snippets.

@akorobov
Last active October 11, 2015 20:28
Show Gist options
  • Save akorobov/3914705 to your computer and use it in GitHub Desktop.
Save akorobov/3914705 to your computer and use it in GitHub Desktop.
Pomodoro script to get current active omnifocus tasks
# this goes into Pomodoro.app/Contents/Resources/getToDoListFromOmniFocus.applescript
on sort(_list)
set text item delimiters to {ASCII character 10}
set _list to _list as string
set _list to paragraphs of (do shell script "echo " & quoted form of (_list) & " | sort -f")
set text item delimiters to ""
return _list
end sort
tell application "System Events" to if exists process "OmniFocus" then
tell application "OmniFocus"
tell default document
set due_soon to a reference to setting id "DueSoonInterval"
set due_soon_interval to ((value of due_soon) / days) as integer
set due_date to (current date) + due_soon_interval * days
set tasknames to {}
set _list to flattened tasks whose (blocked is false) and (completed is false) and ((in inbox is equal to true) or (flagged of containing project is true) or ((status of containing project is active) and ((due date is less than or equal to due_date) or (due date of containing project is less than or equal to due_date))))
repeat with _task in _list
set _p to container of _task
set _pclass to class of container of _task
set _name to name of _task
# add prefixes
if (_task is in inbox) then
set _name to "inbox: " & _name
else
set _name to (name of _p) & ": " & _name
end if
set tasknames to tasknames & _name
end repeat
set tasknames to my sort(tasknames)
return tasknames
#get name of every flattened task
end tell
end tell
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment