Skip to content

Instantly share code, notes, and snippets.

@brandonpittman
Last active December 21, 2015 02:59
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brandonpittman/6238756 to your computer and use it in GitHub Desktop.
Save brandonpittman/6238756 to your computer and use it in GitHub Desktop.
Smartly open perspectives in OmniFocus.
--The most current version of SmartPerspective is now in a GitHub repo. (https://github.com/brandonpittman/OmniFocus/blob/master/SmartPerspective.applescript)
on run
open_perspective()
end run
on open_perspective()
tell application "OmniFocus"
tell default document
if (count inbox tasks) > 0 then --this is for your Inbox
my conditions("Inbox")
return
end if
if number of available tasks of flattened project "Daily" > 0 then --this could be titled "Routine" possibly
my conditions("Daily")
return
end if
if (count (every available task of every flattened context whose flagged is true)) > 0 then
my conditions("Flagged")
return
end if
if (count (every available task of every flattened context)) > 0 then
my conditions("Next Actions")
return
end if
if visible of front document window is true then
my conditions("Someday")
end if
end tell
end tell
end open_perspective
on conditions(perName)
tell application "OmniFocus"
tell default document
if visible of front document window is true then
set perspective name of document window 1 to perName
else
make new document window with properties {perspective name:perName} at end of document windows
activate
end if
end tell
end tell
end conditions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment