Skip to content

Instantly share code, notes, and snippets.

@tofias
Created June 28, 2012 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tofias/3008488 to your computer and use it in GitHub Desktop.
Save tofias/3008488 to your computer and use it in GitHub Desktop.
AppleScript to toggle Active and Available in Context or Project Mode in OmniFocus
-- OmniFocus Filterer -- toggle Active and Available in Context or Project Mode.
-- Michael Tofias 2012-06-27
-- https://gist.github.com/3008488
set theList to {"1 Active and Available"}
set theList to theList & {"2 Active"}
set theList to theList & {"3 Available"}
choose from list (theList) with prompt "Choose a filter toggle:" with title "OmniFocus Filterer"
set myAnswer to result as text
tell application "OmniFocus"
if myAnswer contains "Active" then
tell document 1
tell document window 1
set theSBProperties to properties of sidebar
set theGroupId to selected smart group identifier of theSBProperties
set theType to theGroupId as Unicode text
try
if theType contains "projects" then -- PROJECTS OR CONTEXTS
if theGroupId is "remaining-projects" then
set properties of sidebar to {selected smart group identifier:"active-projects"}
else
set properties of sidebar to {selected smart group identifier:"remaining-projects"}
end if
else -- PROJECTS OR CONTEXTS
if theGroupId is "all-contexts" then
set properties of sidebar to {selected smart group identifier:"active-contexts"}
else
set properties of sidebar to {selected smart group identifier:"all-contexts"}
end if
end if
on error
display alert "Something went wrong trying to set the sidebar filter."
end try
end tell
end tell
else
set theType to "notset" as Unicode text
end if
if myAnswer contains "Available" then
tell content of first document window of front document
set theProperties to properties
set currentAvFilter to selected task state filter identifier of theProperties as string
try
if theType does not contain "notset" then
if theType contains "active" then
set properties to {selected task state filter identifier:"incomplete"}
else
set properties to {selected task state filter identifier:"available"}
end if
else
if currentAvFilter is "incomplete" then
set properties to {selected task state filter identifier:"available"}
else
set properties to {selected task state filter identifier:"incomplete"}
end if
end if
on error
display alert "Something went wrong trying to set the availability filter."
end try
end tell
end if
end tell
-- Copyright (c) 2012 Michael Tofias
-- http://www.opensource.org/licenses/mit-license.php
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment