This Week's Sponsor:

Kolide

Ensure that if a device isn’t secure it can’t access your apps.  It’s Device Trust for Okta.


Automating Podcast Sessions in Audio Hijack 4 with Shortcuts and Timery

Audio Hijack 4 and Timery.

Audio Hijack 4 and Timery.

For the past week, I’ve been rethinking my approach to time tracking with the Timery app with a focus on simplicity and automation. I appreciate the insights into my habits and patterns afforded by time tracking and Timery’s excellent Reports view, but lately I’ve felt like my setup with projects, tags, and sub-tasks was too convoluted since it was based on a structure I designed years ago.

My daily routine is different now – and it’ll continue to change in 2022 – and I wanted to get rid of the overhead caused by a time tracking system that was too granular. For time tracking to be effective, you need to remember to start a timer whenever you’re working on something; too much friction in the process – such as having to carefully pick from a list of similar projects – defeats the whole purpose of it. There’s also the opposite problem – forgetting to stop a long-running timer – which John explained and fixed in a separate story for Automation April.

So I went back to the drawing board of my Timery projects and reorganized everything with simplicity and ease of activation in mind. I cleaned up my saved timers and shortcut that activates those timers, which I can now trigger system-wide via Raycast on the Mac and the Shortcuts widgets on iPad. I split my work projects into three main areas – MacStories, Club, and podcasts – removed redundant sub-tasks, and grouped related activities under the same tags for more reliable filtering.

How I access my saved timers from the Home Screen.

How I access my saved timers from the Home Screen.

The approach worked well for MacStories and the Club, but podcast timers turned out to be a different beast. You see, when I sit down to record a show like Connected or AppStories, I need to take care of key tasks such as making sure my audio inputs are correct, checking out notes for the show’s outline and intro, and keeping an eye on the Connected audience in Relay’s Discord server. These tasks distract me from time tracking and, as a result, I often forget to start a timer for when I begin recording and, conversely, stop the timer when I’m done. I could automatically start a timer when a calendar event for a show is due in my calendar, but that also doesn’t work for me since it doesn’t account for the time before we actually record the show when I may be chatting privately with Myke and Stephen. Wouldn’t it be great if there was One True Way to automatically start tracking my real recording time when I start talking into the microphone for a show?

As it turns out, thanks to the latest update to Audio Hijack – the new version 4.0 that recently launched on macOS – there is. So for this week’s Automation April story, I’m sharing the custom system I created to trigger a single shortcut that starts time tracking in Timery based on the show I’m recording in that specific moment. Let’s take a look.

Audio Hijack Automation

The latest version of the amazing Audio Hijack by Rogue Amoeba (which I’ve used for years to record my microphone’s input as well as a backup recording of Skype/Zoom/Discord calls) comes with a new Scripting section that you can access from the right sidebar of a recording session. Here’s what it looks like:

The new Scripting tab in Audio Hijack 4.

The new Scripting tab in Audio Hijack 4.

The Scripting tab allows Audio Hijack to automatically execute specific actions based on session events. There are built-in steps (which you can see above) that let the app perform things I’ve always done manually when a recording stops, such as trashing audio files shorter than five seconds (for all those times when you need to test your inputs quickly and end up creating dozens of useless files) or opening the folder of your recorded files in Finder. These automations can be easily created by picking the ‘Recording Stop’ event in Audio Hijack and selecting one of the built-in actions provided by Rogue Amoeba.

Built-in scripts in Audio Hijack 4.

Built-in scripts in Audio Hijack 4.

In addition to offering built-in actions, Audio Hijack 4 comes with a JavaScript automation engine (documented here) to run custom scripts when specific events occur in the app. When I started looking into this (inspired by the work Jason Snell has done with this kind of automation), I quickly realized two things: I can run a script when a session starts, not just when a recording stops; and I can create my own script that runs a shortcut in the Shortcuts app with support for passing input text to the shortcut. Specifically, the latter is made possible by the app.runShortcut() method that lets you invoke a shortcut by name, in the background, with the ability to send text to it.

The Script Library in Audio Hijack 4.

The Script Library in Audio Hijack 4.

That got me thinking: when I start recording a show, I could run a script that fires off a shortcut that contains a Timery action to start time tracking. I don’t want to manually tell Shortcuts which podcast I’m recording, but Audio Hijack can help here as well: the app can pass the name of the session that just started to Shortcuts. If I named my Audio Hijack sessions with the same name I use for each podcast project in Timery, does that mean I could invoke one shortcut that knew exactly what podcast I started recording?

My podcast projects in Timery have the same names of the podcast sessions in Audio Hijack.

My podcast projects in Timery have the same names of the podcast sessions in Audio Hijack.

The answer is yes, and the solution was quite simple to implement. In Audio Hijack, I created the following script:

// open the Session's window and bring Audio Hijack to the front
// #needsSession

if (event.session == null)
    return;

var dict = '\{"' + event.session.name + '\" : \"recording\"}'

app.runShortcut('Podcast Timers', dict)

To create a custom script in Audio Hijack, you have to open the Script Library window (⌘L) and click ‘New Script’ in the bottom left corner. As you can probably tell from the code above, the script sends the name of the current session (when it starts) to a shortcut called Podcast Timers. The shortcut receives input text from Audio Hijack in the form of a dictionary that contains the name of the session and a ‘recording’ value. The input text looks like this:

{"Connected" : "recording"}

The shortcut itself is pretty straightforward: when it runs, it checks whether there’s some input text or not. If there isn’t, it means the shortcut was started manually from the Shortcuts app or widget, so I’m prompted to pick a show. In this case, I have to select one of my shows and tell Shortcuts if I’m recording or working on show notes. The ‘recording’ and ‘show notes’ value will be used as a tag by Timery to categorize my work between recording time and research.

If I run the shortcut manually, I have to pick the podcast I'm recording.

If I run the shortcut manually, I have to pick the podcast I’m recording.

If the input text has any value, it means it was activated by something else externally; specifically, it assumes Audio Hijack passed a Dictionary to it. In this case, a conditional block at the beginning of the shortcut parses the dictionary and saves the key (the session name) as a Project variable and the value (the ‘recording’ bit) as a Tag variable. I talked about conditional blocks and explicitly setting named variables in the second Automation April workshop for Club Discord members, so go listen to the episode if you missed the live recording.

If the shortcut has input, the text sent by Audio Hijack is parsed as a dictionary.

If the shortcut has input, the text sent by Audio Hijack is parsed as a dictionary.

At this point, regardless of whether Podcast Timers was run manually or triggered by Audio Hijack, the shortcut has everything it needs to start tracking my time. A single ‘Start Time Entry’ action uses the Project and Tag variables to assemble the template for a new timer, which Timery starts right away. At the end, I get a notification showing me that a timer was successfully started.

Even with two potential scenarios, the shortcut uses one Timery action to start tracking my time.

Even with two potential scenarios, the shortcut uses one Timery action to start tracking my time.

This setup is beautiful and everything I’ve always wanted from Audio Hijack. Now whenever I click ‘Run’ to start a recording session, the shortcut executes in the background and, a second later, I get a notification telling me that the correct timer was started by Timery. I don’t need to think about tracking my time anymore since the one action I have to perform anyway – recording myself – is now tied to time tracking. I can’t forget because the computer remembers to do it for me, which is the whole point of user automation.

The only downside of this approach: because Audio Hijack scripts block the main thread of the app, I see a beachball for a second in Audio Hijack, which automatically disappears as soon as the shortcut has finished running. This is a compromise I can live with for now, but I wonder if Rogue Amoeba could figure out a way to run scripts asynchronously without blocking the app’s main thread, causing this brief interruption in user interactions. It’s not a big deal, but keep it in mind if you’re planning on triggering shortcuts that take a while to run.

The final step of this process was creating another automation in Audio Hijack that stops time tracking in Timery when I’m done recording a show. For this, I created another custom script, which is easier than the first one since it only triggers a shortcut by name, without passing any input text to it:

// open the Session's window and bring Audio Hijack to the front
// #needsSession

if (event.session == null)
    return;

app.runShortcut('Stop Time Tracking')

The shortcut itself is a very simple one: it’s a one-action Timery shortcut that is configured with ‘Show When Run’. This way, when a timer stops, I get a visual confirmation in the middle of the screen that shows the timer’s elapsed time too.

A simple shortcut to stop time tracking.

A simple shortcut to stop time tracking.

This is what I see when I stop a recording.

This is what I see when I stop a recording.


I’m incredibly happy with this new, more reliable automation I set up for tracking how much time I spend recording podcasts each week. The folks at Rogue Amoeba have done a remarkable job exposing data from Audio Hijack sessions via JavaScript, and although I wish Audio Hijack offered visual Shortcuts actions to retrieve data for active sessions, I can live with this JavaScript-only solution for now. The ‘Scripting’ tab is, at least for me, the most important addition to Audio Hijack 4: it compensates for the lack of automations and third-party app triggers in Shortcuts for Mac (I really hope to see third-party triggers in iOS 16 too), and it has allowed me to configure the automated time tracking system I’ve always wanted for my podcasts.

You can download the two shortcuts I covered in this story below or in the MacStories Shortcuts Archive; obviously, unless you’re John, Myke, Stephen, or Shahid, you’ll have to modify the first one with the names of the podcasts you host.

Podcast Timers

Start a podcast timer in Timery by picking from a list of shows. The shortcut supports manual execution as well as input text passed by Audio Hijack.

Get the shortcut here.

Stop Time Tracking

Stop the current timer in the Timery app and show elapsed time.

Get the shortcut here.


You can also follow MacStories’ Automation April coverage through our dedicated hub, or subscribe to its RSS feed.

Kolide: Endpoint Security Powered by People; Try for Free!

Unlock More with Club MacStories

Founded in 2015, Club MacStories has delivered exclusive content every week for over six years.

In that time, members have enjoyed nearly 400 weekly and monthly newsletters packed with more of your favorite MacStories writing as well as Club-only podcasts, eBooks, discounts on apps, icons, and services. Join today, and you’ll get everything new that we publish every week, plus access to our entire archive of back issues and downloadable perks.

The Club expanded in 2021 with Club MacStories+ and Club Premier. Club MacStories+ members enjoy even more exclusive stories, a vibrant Discord community, a rotating roster of app discounts, and more. And, with Club Premier, you get everything we offer at every Club level plus an extended, ad-free version of our podcast AppStories that is delivered early each week in high-bitrate audio.

Choose the Club plan that’s right for you:

  • Club MacStories: Weekly and monthly newsletters via email and the web that are brimming with app collections, tips, automation workflows, longform writing, a Club-only podcast, periodic giveaways, and more;
  • Club MacStories+: Everything that Club MacStories offers, plus exclusive content like Federico’s Automation Academy and John’s Macintosh Desktop Experience, a powerful web app for searching and exploring over 6 years of content and creating custom RSS feeds of Club content, an active Discord community, and a rotating collection of discounts, and more;
  • Club Premier: Everything in from our other plans and AppStories+, an extended version of our flagship podcast that’s delivered early, ad-free, and in high-bitrate audio.