@radekmie

On Apple Shortcuts

By Radosław Miernik · Published on · Comment on Reddit

Table of contents

Intro

Have you heard of Apple Shortcuts? It’s an app available for all Apple devices designed to automate stuff. I’d never really used it before last year, but I found it somehow… Refreshing? As a developer, I’m rather used to writing code and not wiring it in Scratch-like blocks. The latter turned out to be more fun than I first anticipated, so I dug in more.

Cross-device battery notification

I have two iPads. Both are used primarly for work (that’s what you get when half of your users have them). While one is also my main reading device, the other is almost exclusively used for debugging or trying out interactions on a rather lower-end device (it’s a 2016 iPad Air 2).

That also means the former is charged when needed, and the latter was… Well, let’s say I waited long minutes for it to boot way too many times. I checked whether there’s an option to be notified about it without touching it, but I found nothing except for some 3rd party apps.

Then I realized I could use a battery level trigger to get notified. But how do I ping myself on a different device? I can show a notification, but only on the same device. But I can also add a reminder with a deadline for now, resulting in a notification I wanted:

Charge iPad notification

Re-encoding videos with ffmpeg

I often use the Mac’s built-in screen recording (Screenshot app). Yes, I know there are better apps for it, but this one is more than enough for my needs. My only problem with it is that it produces rather bloated recordings.

I know how to deal with it using ffmpeg:

# 3.9 MB ~> 508 KB
ffmpeg -i "recording.mov" "recording.mp4"

Now, how do I make it easier to work with, i.e., skip the terminal entirely in this flow? Luckily for me, it’s pretty straightforward to run shell scripts, so now it’s all about making it accessible.

That’s where the “Quick Actions” come in! You can add it to the available right-click actions in Finder with one more block in your shortcut. It’ll also show a progress bar in the status bar automatically – nice touch, Apple.

Health data import/export

I’m a number freak, I’m aware. As one, I love to occasionally analyze random data available in the Health app, e.g., chart a running average of my weight with a window I want instead of a monthly one.

How do I get this data out of it, though? I could use an existing 3rd party app, but I’d rather not share it with anyone (especially the GPS tracks). I could make an app myself, but that’s far too much effort.

So I searched for a way of doing it with Shortcuts, and it turned out to be much faster than I thought. The first step is to find relevant Health samples, format them as CSV lines, combine them into a single blob, and show a Save action so I can save it to a file or attach it to an email.

The only downside is that it’s slow – exporting a thousand data points takes a few seconds. I believe it’s a safety net not to hang the phone or something, but it’s not an issue in real-life scenarios (your mileage may vary).

Deployment

An important part of building software is to make it available for your users. The technology dictates whether it’s an installer, a ready-to-run executable, or an in-browser app, but it has to be out there. In most cases, we must also consider their environment: operating system, CPU type (Rosetta 2 is great but not always viable), or browser version.

With Shortcuts, it’s as easy as “Share > Copy iCloud Link” and bam: here’s the ffmpeg quick action. Of course, it only applies if you have an Apple device, but that’s not unexpected. Also, if a shortcut is using an action you can’t access (e.g., Health on Mac or a 3rd party app you don’t have), it will notify you.

There’s no real “marketplace” with shortcuts, but you can browse Apple’s own gallery for some inspiration. As for other sources, r/Shortcuts answered all my questions so far. If you’re looking for the craziest shortcuts imaginable, that’s the place. (Seriously, check out this earnings tracker.)

Conclusion

While I don’t expect to see a flood of “Apple Shortcuts Developer” openings anytime soon, I highly recommend checking it out. In my case, it allowed me not only to automate some daily activities but also not to install any 3rd party apps just to move data here and there.

If you’re not a developer, you can also think of it as a “programming-like” skill you could start your journey with. Sure, it’s not directly something you’ll use at work, but the same mindset applies there: configuration, variables, conditions, loops, and integration with external services (apps).

10 out of 10, would automate again.