• Modern Chaos
  • Posts
  • A Guide to Sync Calendars to your Org Agenda using Shortcuts

A Guide to Sync Calendars to your Org Agenda using Shortcuts

Create org files from your calendar events automatically and use it as a source for your org agenda with Apple Shortcuts.

This blog post explains how I've managed to streamline my calendar events across different accounts into one unified org agenda. The Emacs org agenda is my go-to tool for managing my to-dos and projects.

How it works?

The secret ingredient: Apple Shortcuts on my MacBook.

I create Org files with events, letting Emacs display them in my org agenda. Every day, a Launchd service refreshes my events. It replaces old files with new ones. One file per day. The next 25 events from my calendar.

The beauty lies in simplicity.

Apple Calendar's ease of use lets me respond to meeting requests and connect any calendars with minimal setup. Essentially, Apple Calendar handles the "write" operations while Emacs centralizes the "read" operations.

However, no system is perfect.

The current setup doesn't archive past events. Reflection on prior meetings, their frequency and other details can only be done via Apple Calendar. Not Emacs. But, if you refile the event during the meeting like me, using it as a launchpad for notes, this might not be an issue.

Workflow setup

Apple Shortcut

Download the shortcut here and install it.

You need to update some variables by selecting your own folder. You should also replace or remove the tag :@sam: by your own. You can customize the script and add other org properties to the todo item to match your own workflow.

What does this shortcut do?

  1. Cleans up the event save folder

  2. Fetches the next 25 events from all your calendars

  3. Filters out non-meeting events (eg., holidays, weekdays number)

  4. Saves events as a TODO, tagged with my name and date range.

    Note: there's a bug with the "create file" action that ignores the provided extension. That’s why I improvised with a "replace > add to file" process to get the correct extension.

Schedule the job with Launchd

Download the file here and change the interval if needed. It’s at 10am. Then load the configuration with the command below. Your Apple Shortcut will run every day at 10am:

launchctl load emacs-sync-calendar.plist

You can run it manually to check if everything works. Errors are saved at /tmp/com.emacs.sync-calendar.err

launchctl start ~/.emacs.d/sync-calendar.plist

Emacs org agenda

Now that org files are created automatically, we need to tell Emacs where to look. In your init.el , add the line below to tell org-agenda to pick up your org files created by the shortcut:

(add-to-list 'org-agenda-files "~/<path-to-my-folder>")

Custom agenda view for your meetings

I have a custom agenda view to filter all events coming from my Apple Calendars under a section called “Meetings”:

one of my agenda view

To create a similar section you can add the code below to your custom agenda list:

(setq org-agenda-custom-commands
      '(("g" "Focus agenda view"
          ;; other sections...
          (tags "+PRIORITY=\"C\""
                ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done 'nottodo '("TODO" "PROG")))
                 (org-agenda-overriding-header "Meetings:")))
          ;; other sections...

While not flawless, this setup is a significant stride towards a more streamlined Emacs setup and it’s easy to maintain, enjoy!

Join the conversation

or to participate.