Code Monkey home page Code Monkey logo

omnifocus's Introduction

OmniFocus Library

Notices

  • It's possible that some of these scripts may not work correctly with OmniFocus 3 (as they were all written before OF3 was released). Feel free to let me know if you find anything not working. Pull requests are welcomed.
  • Probably any script in this repo will require the library. Assume you need it.

Why is there a new OmniFocus library?

I had previously written an OmniFocus library using JavaScript for Automation, but it's got issues that vanilla AppleScript does not. Also, I realized that I didn't really need the fancy regex abilities from JavaScript that I thought I needed, so I went back to standard AppleScript. It works just as well, and the source code is a lot more readable. I hope you find this new library useful.

Basic Usage

Put omnifocus.scpt in ~/Library/Script Libraries, or else AppleScript won't know where to find it!

use application "OmniFocus"
use O : script "omnifocus"

tell O
   set sel to selectedItems()
   deferDaily(sel)  # this will set all the selected tasks to start again after completion daily
   setDefer(sel, current date)

   set theTask to findTask("Log food") # find the first task whose name is "Log food"
   set theProject to findProject("Groceries")
   set theContext to findContext("Home")
   set theFolder to findFolder("Routine")

   # Parse using transport text (see below for details)
   parse("Do something! @home ::misc #5pm #tomorrow //This is a note")
end

Transport Text

For those who don't know about transport text, it's a format that OmniFocus uses to parse task information like so:

Do something! @home ::misc #5pm #tomorrow //This is a note

The ! makes Do something a flagged task. @home sets the context to "home". :: is used for matching a project. Both @ and :: will fuzzy match existing contexts and projects. The first # is used for a defer date, while the second # is for a due date. Both support natural language parsing like the inspector in OmniFocus. Word of caution though, if only one # is present, OmniFocus assumes it's a due date. Lastly, // starts the note for a task. While more involved ways of creating OmniFocus tasks exist in the library, you'll find using of.parse as your primary means of creating tasks.

Functions

- selectedItems()
- parse(transportText)
- findContext(contextName)
- findProject(projectName)
- findFolder(folderName)
- findTask(taskName)
- allTasks()
- allProjects()
- allContexts()
- setDue(input, dueDate)
- setDefer(input, deferDate)
- setProject(input, projectName)
- setContext(input, contextName)
- namePrepend(input, prependString)
- nameAppend(input, appendString)
- inboxTasks()
- setComplete(input, booleanFlag)
- setSequential(input, booleanFlag)
- openPerspective(perspectiveName)
- inboxCount()
- errandsCount()
- landAndSeaCount()
- routineCount()
- computerName()
- setRepeat(input, repetitionRule)
- deferDaily(input)
- deferWeekly(input)
- deferMonthly(input)
- repeatDaily(input)
- repeatWeekly(input)
- repeatMonthly(input)
- clearRepeat(input)
- clearDefer(input)
- clearContainer(input) *Only works on inbox tasks.*
- clearContext(input)
- setOnHold(input)
- setActive(input)
- showAbout()
- toggleColon(input)
- setColon(input)
- clearColon(input)
- setPrefix(input, prefix)
- clearPrefix(input, prefix)
- clearPrefixAll(input)
- setConsider(input)
- clearConsider(input)
- toggleConsider(input)
- kindOf(input) *This will be a task, project, context or folder.*
- isProject(input)
- isContext(input)
- isTask(input)
- isFolder(input)

Buy Me A Coffee

omnifocus's People

Contributors

damoclark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

omnifocus's Issues

SmartPerspective applescript ignores folders/projects that only have tasks without contexts.

  • I'm kinda new to this whole GitHub thing, so please forgive me for not forking/pull requesting/etc.
  • I have many projects that only have tasks without contexts.
    • I use contexts as true dependencies; so if a task can be completed basically anywhere, it gets no context.
  • The SmartPerspective applescript treats projects with only tasks without contexts as if they had no available tasks (e.g., nFlagged = 0).
  • I found that this can be fixed by changing the code
    set nFlagged to count (every available task of every flattened context whose flagged is true)
    to
    set nFlagged to count (every available task of flattened contexts whose flagged is true)
  • Apparently "every flattened context" returns only actual contexts, and does not include "missing value" (i.e., no context).
  • Depending on usage, you may wish to change this for each perspective you want to check.
  • Once again, thank you for this awesome script. I'm going to give some thought about how this could be combined with airplane or some other wifi-based location system to run different series of perspectives depending on whether you're at home, at work, etc.
  • Sure wish I had this on OmniFocus 2 for iPhone! :-)

Coercing error in OmniFocus Pomodoro script (OmniFocus 3)

of_pomodoro_error

I get an execution error on two different machines when trying to use the OmniFocus Pomodoro script:

Can't make <<class FCdw>> id 25335 of <<class FCDo>> into type integer. (-1700) I am unfamiliar with AppleScript: is there a solution to this?

Installation issue

Hi. When I use pip to install de package, I get an error message. I'm using anaconda.

(base) MBPdeBenedetto:~ jmbenedetto$ pip install pyomni==0.1.6.1
Collecting pyomni==0.1.6.1
Using cached pyomni-0.1.6.1.tar.gz (43 kB)
ERROR: Command errored out with exit status 1:
command: /Users/jmbenedetto/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/29/7tn4pd3n0_s98m6p6z0cjlvm0000gn/T/pip-install-v1bex1my/pyomni/setup.py'"'"'; file='"'"'/private/var/folders/29/7tn4pd3n0_s98m6p6z0cjlvm0000gn/T/pip-install-v1bex1my/pyomni/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/29/7tn4pd3n0_s98m6p6z0cjlvm0000gn/T/pip-pip-egg-info-i1etf175
cwd: /private/var/folders/29/7tn4pd3n0_s98m6p6z0cjlvm0000gn/T/pip-install-v1bex1my/pyomni/
Complete output (12 lines):
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/29/7tn4pd3n0_s98m6p6z0cjlvm0000gn/T/pip-install-v1bex1my/pyomni/setup.py", line 3, in
import pyomni
File "/private/var/folders/29/7tn4pd3n0_s98m6p6z0cjlvm0000gn/T/pip-install-v1bex1my/pyomni/pyomni/init.py", line 2, in
from pyomni.pyomni import PyOmni
File "/private/var/folders/29/7tn4pd3n0_s98m6p6z0cjlvm0000gn/T/pip-install-v1bex1my/pyomni/pyomni/pyomni.py", line 10, in
from pyomni.webdav.WebdavClient import CollectionStorer
File "/private/var/folders/29/7tn4pd3n0_s98m6p6z0cjlvm0000gn/T/pip-install-v1bex1my/pyomni/pyomni/webdav/WebdavClient.py", line 885
except AuthorizationError, e:
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Can't load lib

Having trouble loading the library, consistently getting an error.

Complied script placed here: https://cloudup.com/chgGvgXxRo0

Node app creating script here: var script = "of = Library('OmniFocus');"

Getting this error: err { [Error: 0:2: syntax error: A “of” can’t go here. (-2740) ] appleScript: 'of = Library(\'OmniFocus\');', exitCode: 1 }

Hierarchical contexts

I'm trying to manage delegated tasks in OmniFocus by adding a "delegated" context and sub-contexts "Alice", "Bob", etc. for each person to which I'm delegating a task. My objective is to write a script to send to each person a reminder with a list with delegated jobs by email.

In my tests I was not able to recognize that "Alice" is a sub-context of "delegated". This is, when querying the context for a task "Demo" with context "Delegated : Alice" task.context.name() returns just "Alice" but not the parent "Delegated".

Is there a way to access the hierarchy of contexts?

Function documentation

Hi. I have looked at the readme and the website but I could not find much information on the functions and what they do. They do not all seem intuitive to me (but maybe that is because I have not written applescripts for OmniFocus before.

Do you think I should be looking somewhere else for this information or do you think I'll be fine once I get started?

Thanks

SmartPerspective applescript ignores tasks that inherit flags 2+ levels deep.

  • Edi Venturin noted that his code for the Flagged section doesn't pick up tasks that inherit flags 2+ levels deep.
  • I think the following code fixes the problem!
            -- Flagged
            set nFlagged to count ((every flattened task) whose (flagged is true) and (completed is false) and (blocked is false))
            if (nFlagged) > 0 then
                my conditions("Flagged")
                return
            end if
  • I hope it's helpful.

Where is OmniFocus JavaScript for Automation (JXA) Library?

Hi Brandon (@brandonpittman),
Can you please provide a link to the JXA script library you previously published for OmniFocus?
I much prefer JXA over AppleScript, and would like to use it.

I realize it is depreciated now, but it would still be helpful to me.
Thanks.

You wrote:

I had previously written an OmniFocus library using JavaScript for Automation, but it’s got issues that vanilla AppleScript does not.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.