'Magic' daily planning script


#1

Here’s an Automator script I spun up to meet some very specific needs of mine. Every night (or first thing in the morning) I try to map out my day, and this script does most of the work setting this up.

This script intelligently pulls in information from:

  • Tasks with the ‘@due’ tag (in the current document)
  • Events from Calendar.app
  • Schedule templates stored in a “Schedule Templates” project

And this is what the script does:

  • Renames the ‘Today’ project to ‘Yesterday’
  • Creates a new ‘Today’ project with…
    • A ‘Schedule’ project prepopulated with tasks from a schedule template (a ‘Schedule Template’ project anywhere in your document) plus a list of the day’s events from Calendar.app
    • An empty ‘Work Tasks’ project
    • An empty ‘Secondary Tasks’ project
    • And a ‘Suggested Tasks’ project, listing (just the names of) ‘Due Tomorrow’ tasks and ‘Due Soon’ tasks (i.e. tasks due in the next 7 days)

The idea is that this will set up a plan that can be quickly edited and turned into a complete plan for the day.

For example, this script will spit out a nearly-ready daily plan that looks something like this:

Today:
    Schedule:
        - Meditate
        - Morning Walk
        - Lunch
        - [Other not-quite-task/not-quite-calendar-event items that are part of your routine]
        - (10:00 AM) Meeting with Janet
        - (1:15 PM) Tennis with Antonia
        - [Any of today's events from Calendar.app]
    Work Tasks:
    Secondary Tasks:
    Suggested Tasks:
    	Due Today:
            - Call Michael about party
            - Finish editing chapter 2
            - [Any item that matches the "@due >=[d] -12 hours and @due <=[d] +12 hours" search query]
    	Due Soon:
    	    - Apply for Templeton Grant
            - [Any item that matches the "@due >=[d] +12 hours and @due <=[d] + 7 days" search query]

In the future, I plan on pulling in different schedule templates depending on the day of the week.

I’m also now thinking that I might abstract away all of my idiosyncratic formatting and instead create a more powerful ‘magic template’ script that:

  • When triggered, asks the user which ‘magic template’ to create
  • Inserts an outline that’s based on a template document
  • And that template document can include either static text or plantext ‘commands’ to generate lists based on searches

Any feedback/bug reports much appreciated!

(I’ll add this to the extensions wiki once I’m sure I’ve caught any bugs/finalized the script)

Quick Task Planning.workflow.zip (148.1 KB)


Feedback on a potential 'Magic Templates' script
Javascript + Calendar.app = crashing?
#2

I have just been trying to figure out how to do a daily recurring list that works in the way I do, and this looks like it might do the trick. I’ll play with it and let you know if I have any useful feedback, but thanks for doing this!


#3

Great script. It would be great if the due dates were carried over along as it gets transferred to the Due today or die soon sections.


#4

I was thinking that these copied-over tasks shouldn’t have tags because that would then duplicate data, resulting in messy search results. Can you tell me more about your use case? Would you mind the duplicated data?

I think I’ll include this as an option for the ‘magic templates’ script I’m working on.


#5

I’m loving this script and have run into just one problem. It appears that your calls into the calendaring system aren’t returning exceptions to recurring events (e.g., I have a weekly 1on1 on Tuesdays at 10AM with David but this week it was moved to Thursday at 8AM). Non-exception cases of recurring events seem to work splendidly and they appear in the list o’ items in the Schedule project.

Have you any suggestions?


#6

Hmm. I tried recreating the problem by creating a dummy recurring event, and making a single exception. But the script spat out the right listing for me. There might be something else going on.

The calendar calls are currently run through Automator instead of the javascript for automation environment. The javascript interaction with Calendar.app can be really slow (and doesn’t seem to work for for my large calendar), but I’m hoping to figure out a way to use the more speedy/reliable (but more difficult to use) EventKit framework to make these calendar calls in the future. If I can implement that, all calendar manipulation/search should be more flexible–and whatever problems you’re running into should be fixed/easier to debug.


#7

Thanks for looking into it. I can work around this for the time being and would be happy to help you test out an Event Kit-based implementation.


#8

FWIW a rough sketch of some JS code for EventKit here:


#9

Today dawned and now the workflow just crashes: “The action ‘Run JavaScript’ encountered an error.” Other than a theme adjustment nothing is different from yesterday (I’m pretty sure) and things fail the same way if I quit TaskPaper, replace the backup theme I was using while testing yesterday, restart TaskPaper, and try the workflow.

My system.log shows the following during the run of the workflow today and didn’t show this on any runs of the workflow yesterday.
Jul 1 13:18:02 Georges-MacBook-Pro WorkflowServiceRunner[39227]: WorkflowServiceRunner received error running Workflow Service at /Users/georgegoodman/Library/Services/Quick Task Planning.workflow: The action “Run JavaScript” encountered an error.

Any ideas?


#10

I’m sorry you had to deal with that! I put this script together quickly, and I wasn’t particularly careful about handling exceptions. I haven’t had time in the past few days to work on an updated script, but the plan is to use what I learned here to put together a better-thought-out/more stable/more robust ‘magic templates’ script in the next week or so.

In the meantime, the script shouldn’t run into problems so long as everything it ‘expects’ to be there is there. (The theme shouldn’t be affecting anything.) So that means: A ‘Today’ project, a ‘Schedule Templates’ project, events for the day. If those are all there, the script should know what to do. (The updated script won’t crash when it can’t find what it’s looking for.)


#11

Aha! The problem was that I hadn’t put the Schedule Templates project in-place in my new TP file.

Thanks for all you’re doing!