Integrating Drafts and Tot

Contents

Drafts, by AgileTortoise, is my ubiquitous note app. I use it for capturing ideas, drafting content, shopping lists, general note taking, and more besides. The content is often temporary, but when it isn’t, the content gets reflowed off into files (such as in one of my Obsidian vaults), social media posts, e-mails, or some other channel. Last year I also began using another note app - Tot by the IconFactory.

Tot has a very different view of notes. It is a much simpler app and is opinionated in how complex it can get. But, what it gave me on the Mac was a free menu bar app that I could keep snippets on for short periods.

In real world terms, I think of Drafts as my ubiquitous pocket notebook, and Tot as the pad of last few sticky notes on my desk. There is undoubtedly overlap, and I am sure I could make Drafts provide near identical functionality to Tot. However, having a distinction between them works for me, and having Tot as a separate app to fulfil a niche requirement in my workflows has stuck.

The only friction that occurred is where I wanted to transfer information between the two apps. But I’ve been able to smooth that over and I’m going to explain how in the remainder of this post.

A Difference in Automation

Drafts is great to work with in terms of automation. It has its native Drafts actions, a broad range of functionality available via Apple Shortcuts, and support for x-callback-urls. Its AppleScript is extremely limited, but that can generally be worked around with Shortcuts and URL calls to trigger actions in Drafts.

Tot on the other hand is more limited. It too has quite limited AppleScript support, good Shortcuts support, and no bespoke automation platform built-in.

While I could have built a cross-platform solution using just Shortcuts, I decided instead to develop a Drafts action group and to trigger as much of the Tot interactions as I could via URL; falling back to Shortcuts only where absolutely necessary. By focusing on Drafts actions, I gave myself the best set of options for interacting with the two applications, and also a mechanism (via the Drafts directory) for easily making the solution updatable and extensible - the current Shortcuts options for maintaining complexity in Shortcuts alone is overly cumbersome taking longer to develop and to debug unless you split them into a large set of shortcuts (my approach for my own complex shortcuts), which then makes it difficult to share with others.

Utility Actions

The Drafts action group includes several actions that are hidden on both the Mac and on iOS (including iPadOS). These actions are utility actions called by other actions and are a way of me including in effect a library of action steps in the action group without repeating them in each action that uses them (a maintenance headache for sure), and without making them overtly visible to users who would never need to trigger them directly.

If you want to see the listings, there are options to force Drafts to show actions normally hidden to that OS in the action listing.

Each of these actions fulfils a function that is reused by one or more sets of actions in the group.

Action Description
Get Tot Content (Raw) Get the content of a Tot dot.
Get Tot Content Get the content of a Tot dot, but checking for emptiness.
Get Tots Content (Raw) Get the contents of all of the Tot dots combined.
Get Tots Content Get the contents of all of the Tot dots combined, but checking for emptiness.
Insert Tot Content into Draft Inserts the content of a Tot dot into the draft at the cursor position.
Prepend Tot to Draft Inserts the content of a Tot dot into the draft at start of the draft.
Append Tot to Draft Inserts the content of a Tot dot into the draft at end of the draft.
Create Draft From Tot Creates a new Tot dot from the selection/content of the draft.
Select Tot Select a draft by colour/position.
Set Tot Content (Raw) Sets the content of a Tot dot.
Set Tot Content Sets the content of a Tot dot, but checking for overwriting.
Prepend Tot Content (Raw) Places content at the start of a Tot dot.
Prepend Draft Selection to Tot Places draft selection/content at the start of a Tot dot.
Append Tot Content (Raw) Places content at the end of a Tot dot.
Append Draft Selection to Tot Places draft selection/content at the end of a Tot dot.
Replace Tot Content Replaces the content of a Tot dot.
Replace Tot Content With Draft Selection Replaces the content of a Tot dot with the draft selection/content.
Replace Tot Content with Draft Content Replaces the content of a Tot dot with the content of a draft (regardless of selection).
Clear Tot Content Removes content of a Tot dot.

The actions use a couple of custom Drafts template tags for the inter action sharing of data. Where a particular Tot dot needs to be specified, tot_id is used to hold the number of the Tot dot (1 through 7 inclusive). Where the content of a Tot dot is required, then this is held in tot_content. If you looks at how the actions are built, you will see these coming up time and again.

Shortcuts, AppleScript, and URLs

Tot has an interesting approach to automation. I think most of the automation with Tot is best handled through Apple Shortcuts. The support in that tool is very good. The support for AppleScript and URL schemes on the other hand is a little unusual, but functional. It may seem odd therefore that if you look through the utility actions, you find they focus heavily in the URL scheme, with a little AppleScript thrown in, and just one use of an AppleShortcuts shortcut.

As I noted above, I was trying to keep my use of Shortcuts minimised for this as I could see it easily growing to either one very complex and difficult to maintain shortcut, or to as many shortcuts as I have actions above - which is too many to be asking someone else to download and install. It turned out that using URL schemes I could do everything on any platform, except get the content of a Tot dot. To do that on the Mac, I need to use AppleScript too. That isn’t available on the iPhone and iPad, so I turned to creating a shortcut.

I very rarely use Tot on mobile (and I don’t have it for my watch), but I bought it as I wanted to support the development of the application. But that’s my own workflow, and others may be different, so rather than excluding iPhone and iPad users, I figured it wasn’t going to be too onerous to ask them to download one shortcut for those devices.

You can see in the Get Tot Content (Raw) action, the first two steps are enabled for macOS, and the third step is enabled for iOS. You may however be surprised to note that this isn’t a Shortcuts action step as provided by Drafts. Instead, this is an action step that uses an x-callback-url to run the shortcut.

Why would I do that? Well the reason is because I can look at the return of the call. Sure I can get the result (the content of the Tot dot), but I can also check for success of the call. If I get a successful call, but the result is empty, I know the Tot dot was empty. If I get an unsuccessful call, and because I know I’m doing the correct call, I can infer that the shortcut does not exist on the user’s device, at which point I can prompt them to download and install it. That is incredibly useful, and worth the extra effort over using the built-in action step.

Scale of the Action Group

Integrating Tot and Drafts might at first have seemed quite straight forward at first. A user might want to pull content from a Tot dot into a draft, or push content to a Tot dot from a draft. However, having looked through the list of actions above, you can probably start to see a bit of additional complexity creeping in with the different ways in which you might want to move that information around between the two applications.

My personal use grew over time. I started out with just a few actions, but every now and then I came across a desire to do some sort of variation. I typically did them manually, but eventually I made the time to think things through a little more and tried to figure out a broad range of options that other users of these two applications might find useful too.

Functionality Delivered

The action group contains over 100 actions that can be triggered by the end user, plus all of the utility actions noted above. Here’s a rough breakdown of the functionality:

  • Display some information about the Tot-ality action group.
  • Create a draft from the content of a Tot dot (choice, or specific Tot dot).
  • Create one draft from all of the Tot dots merged together.
  • Create one draft from each of the Tot dots with content.
  • Replace the selection in the current draft with the content of a Tot dot (choice, or specific Tot dot).
  • Replace the selection in the current draft with all of the Tot dots merged together.
  • Prepend/append the current draft with the content of a Tot dot (choice, or specific Tot dot).
  • Prepend/append the selection in the current draft with all of the Tot dots merged together.
  • Move the content of a Tot dot (choice, or specific Tot dot) into a new draft (Tot dot is empty afterwards).
  • Move tall Tot dots into new drafts (all Tot dots are empty afterwards).
  • Create a Tot dot (choice, or specific Tot dot) from the current draft (selection/content).
  • Replace the content of a Tot dot (choice, or specific Tot dot) from the current draft (selection/content) - i.e. no prompt to overwrite.
  • Prepend/append a Tot dot (choice, or specific Tot dot) with the content of the current draft (selection/content).
  • Move the content of a draft in to a Tot dot (choice, or specific Tot dot) and archive/trash the draft afterwards.
  • Clear a Tot dot (choice, or specific Tot dot) of any content.

Why Call the Action Group “Tot-ality”?

Rather than being some sort of riff on “Tot” and “reality”, this was in fact more a focus on “Totality” (well, and “Tot”). I wanted to try and cover as many options as I reasonably could (and I may well increase it in the future), one could reasonably say … in its totality.

Totality is also a term used to describe a full solar eclipse, which is what the dots reminded me of in the Tot application, and so there was a nice visual duality there too.

As a result, the name seemed rather apt.

Conclusion & Action Group Download

What started out as a few simple actions has grown into what feels like an extensive action group. The relatively simple functionality is underpinned by a small library of utility actions that utilise JavaScript, URL schemes, AppleScript and Apple Shortcuts. It even includes functionality that checks if a user has a particular Shortcuts shortcut installed and prompts them to download it if they don’t.

I think there is actually a lot of power and at least a couple of neat features in this action group, and hopefully the run through above gives some sense of that.

If you are a Mac user, I would definitely recommend trying out Tot. It is a free application on the Mac, and you may find it fills a niche for you. If you use Apple products at all, then Drafts is definitely something you should try. The free version is hugely powerful, and you only need the pro subscription if you want to start tailoring things to your own specific needs.

Author: Stephen Millard

Buy me a coffeeBuy me a coffee



Related posts that you may also like to read