How To Automate Tasks On Your Mac and iPhone

CC0 1.0

(Updated on 20220630 — Added sample code github repo) Just sharing some tips on how I automate my workflow on Mac and iOS. I use a combination of Shortcuts, Automator, Apple Script and Shell scripting. It’s not actually that technical, you just need to play around with these apps. Let’s jump right in. I left a note about the history of Mac automation at the bottom for anyone interested. Like most notes I write, I will come back to edit it every now and then. Stay tuned.

You can find the sample code at https://github.com/eplt/Mac-Automation

This article is getting a bit long, and I have covered the following automated tasks:

  1. Autoloading Websites Each Morning (Mac)
  2. Autoloading Apps Each Morning (iOS)
  3. Automate your “Going Home” ETA routine (iOS)
  4. Keyboard Shortcuts
  5. Use NFC to trigger iOS Shortcuts
  6. Use Automator to watch out for Folder Actions
  7. Use Accessibility Feature to enable Back Tap as extra “buttons” on your iPhone
  8. File Sharing and Access

Autoloading Websites Each Morning (Mac)

I autoload my daily websites at 7am each morning. There are a few sites that I visit every morning, some for collecting login rewards, some just for news and info. So I script these. Use a cronjob to do these. Yes, I can do it with Automator too, but it is very simple with cron. This is how to do it.

  1. Open Terminal app. (Assuming you don’t know what I am talking about, you will see a black window where you can type some text.)
  2. Type the following (Copy and Paste), without the quotes: “env EDITOR=nano crontab -e”
  3. Then copy and paste the following lines into it. To exit the editor, click Control-X, Then “Y” to confirm the saving of the file. (Now you have created your cronjob.)
    In this example, it will open these 4 sites at 7am, your computer local time, with Safari browser.
0 7 * * *  open -a Safari http://www.bbc.com/news
0 7 * * * open -a Safari http://money.cnn.com
0 7 * * * open -a Safari https://flipboard.com/section/technology-c5o31di9kg9ea7p6
0 7 * * * open -a Safari https://www.macrumors.com

Autoloading Apps Each Morning (iOS)

It’s common for apps in China to reward users for regular login, you get extra points or other rewards. So I just use Shortcuts for some time based automation. It is very easy to setup and you can even include some pre-assigned text to the clipboard before opening the app. (Tips, add a short 1 second delay might sometime help the steps to run “better”.)

Automate your “Going Home” ETA routine (iOS)

Yes, I am not the most romantic person in the world, and I wrote a script to send out an automated iMessage with my estimated time of home arrival. So just as I leave office or just on my way home, I just click an icon on my main screen to run this script. Good to manage expectations, right? Oh, the travel time is actually quite accurate. I am sharing the iCloud link to the script here for you to play around with. But essentially, it does a few things:

  1. When you add the script, you needc to set it up. You will need to specify your home location and iMessage recipient number when you import the script.
  2. When you run it, it will select a randomised greeting word from the list, so the message is just that little bit more “customised” or “personalised”. You should change this to your style. :)
  3. It will ask you for the mode of transport when you run the script, but you can fix it to your default transport mode if you want to.
  4. It will then work out the travel time to your home location. I have also included the actual arrival time because it can be annoying to have to check the message sent time and calculate current time difference. (There is a bug in the Travel Time feature in Shortcut, if you choose “Public Transport”, it won’t directly give you the Arrival Time, so I wrote out as part of the script to calculate it. It will only work if you system language is English and travel time is less than a day, you can see in the script that it only calculate based on hours and minutes.)

Automate set timer when you receive this ETA iMessage from someone

Now the fun bit, on receiving an iMessage, I have a script to process it too. Not just an automate a reply with random sweet words, but I use the Arrival Date calculated to set the timer for 3 mins before expected arrival. So I will always be on time and ready to meet and greet in person. :)

There isn’t a way to share an Automation script, so I just share the Shortcut script for processing the message from clipboard here. You can use the same steps to setup the automated timer.

A few tips:

  1. It’s important to know the language of the system the sender/receiver are using because we are using our own text matching to calculate the Arrival Time. If you don’t use Public Transport at all, the other travel modes have Arrival Time which is easier to process in different languages.
  2. You can easily send the message via WhatsApp, WeChat or other chat apps, they have Shortcuts function to send messages. But you cannot automate the processing upon receiving it, currently can only be done using iMessage.
  3. You can use similar ideas in these scripts to semi-automate these inter-device messaging and timer setting.
  4. If you want to fully automate alerts, can try using a shared calendar (or shared reminder list). So you automate a new calendar event with alert for each “going home eta” event.

Keyboard Shortcuts

It is still quicker to just press a key to get certain things done when you are at your desk. I have mapped a few key functions to special key combinations. I am still a big fan of Microsoft Natural Keyboard after so many years. But too bad that they don’t write compatible drivers for Mac anymore, so I haven’t been able to use the special keys at the top. (I am aware of some 3rd party utilities to map special keys, but I try to avoid these non-native or official solutions, can be buggy/spammy/scammy/etc.)

For frequently used features, try to map it to a key that you can remember, then force yourself to use it many time. Here are my key mappings:

F6/F7 Change between Chinese and English input, both keys are the same, just switch from Chinese between English input. F6 and F7 so I can access them with index finger from both hands.
F12 Mute/Unmute Button for Zoom. That’s my primary video conf platform and one key mute/unmute is useful. Consider buying a good conferencing speakerphone with a big mute button too.
F8 Direct FaceTime call home. New feature with macOS Shortcuts app. Actually, I have a similar Shortcut on my iPhone, so I can just call home with 1 click on the icon. (example below, I will find ways to share the icloud link soon.)
⌃⇧⌘S
Open Key Websites, similar to the daily cron job script, but this one is manually triggered. Can do that in automater easily (example below).
⌃⇧⌘D Shortdate, I like my YYYYMMDD date format, started using it long time ago when I was in London and had to deal with US formats. So fixing it to this format is always clear. (I don’t really like the 10.1 or 11.11 format for month and day, but I am slowly localising.)
⌃⇧⌘T Longdate, extending the above, but including 24 hour time. Both done with automator too (example below).
⌃⇧⌘K Open Keychain Access
⌃⇧⌘- 10 Dashes, I use 10 dashes to separate sections of my notes or text documents.

A quick reminder:
⌥ Option
⌃ Control
⇧ Shift
⌘ Command

Use Automator to create a Quick Action then map it to your keyboard shortcuts.
You can use Automator to open sites, but I just use it to trigger a Shell Script.
Another technical reason is, if you do it like this, you won’t have per app permission issues, Apple made it rather “difficult” to copy and paste with clipboard automation per app.
Can try to add this https://www.icloud.com/shortcuts/48dd2f6c62e74858bc7310e0161954de then map it to F7.

Use NFC to trigger iOS Shortcuts

Looking for an app on your iPhone is not too hard, I keep my 10–20 most used apps on the first page anyway. But if there is a particular app that you use only at a specific location, using NFC label to trigger it is even easier. You don’t have to unlock your phone, look for it, open it, etc. Just tap your phone on the NFC tag and it opens the specific app. Use Shortcuts to create it on iPhone, just make sure you have some NFC labels around. (Contact me if you need to buy some BeaconGo NFC labels.)

I stuck an NFC label in my bathroom so I can trigger a Shortcut Automation to open the app for my digital scale.

Use Automator to watch out for Folder Actions

When I download files from the web, I am too lazy to file them properly. So I like to put certain filetypes into a folder for sorting later. For example, any ebooks, I will just move them to another folder.

Just open up Automator to create a new Folder Action.
You can filter by different criteria and then process them.

With the current Shortcuts app on macOS, you can’t directly setup automation like on iOS/iPadOS. You will need to use other tools. For folder actions, use Automator to trigger a shell script action. (See screenshot below). Or if you need time based automation, can use Calendar or cronjob to trigger the shortcut.

Use Accessibility Feature to enable Back Tap as extra “buttons” on your iPhone

You can add two extra triggers to your automation shortcuts. System Accessibility > Touch > Back Tap. They are triggered when you double or triple tap the back of your phone. I set up mine to launch the Calculator and the Healthcode app to show my Covid status quickly. You can’t directly select the app as such, so you need to create a shortcut to open the app first, then select the shortcut. Like all of these shortcuts, keep forcing yourself to use it many times to get used to it. (A reminder, these back taps can be a little sensitive.)

File Sharing and Access

Cloud is great for online storage, but I don’t put everything on the cloud. I have nearly 300GB of Photos, 100GB of photos and a few TBs of other files. iCloud, OneDrive, Baidu Pan and others all have options for over a terabyte of storage space. But I don’t trust them with all my files, don’t want the risk of someone getting access to every digital bits of me. Also, I have heard horror stories online of accounts having issues and all files and gmail disappeared. So I use a combination of these: 50GB of iCloud (1 buck a month), 1TB Microsoft OneDrive (part of my Office365 about 50 bucks a year), 10TB Baidu Drive (about 30 bucks a year), Resilio Sync to run my own P2P sync between devices and Cryptomator to encrypt/decrypt whole folder before uploading sensitive data to any of the cloud storage. Most files I put on cloud are not sensitive anyway, but when they might be more personal, I use Cryptomator to encrypt whole folder first. The even more sensitive ones will be protected at file level before adding to Cryptomator folders. (Remember to never lose your keys, you won’t get it back and will be hard/impossible to recover the files.)

I also setup Resilio Sync to on my desktop folders and screenshot folders so all my laptops and desktop computers have all the files I am working on. I considered using Syncthing, it hasn’t got a good iOS client, so I ruled it out, still great for server P2P sync.

https://www.resilio.com/individuals/ — Resilio Sync
https://cryptomator.org/ — Cryptomator

Other tools or services I use:

https://visualping.io/ — To monitor website changes. I use it to watch out for price changes, status changes, new versions, etc, of any particular website. It sends you an email when changes are detected. You can then link it with other workflows by processing the incoming emails.

https://www.selenium.dev/ — I am starting to play with WebDriver for Chrome and Safari. Used iMacro many years ago to automate web testing, taking screenshots, etc.

Background note: Apple has a long history of system automation for non-coders or low-coders. I am not hung up on old legacy tech like Hypercard, OpenDoc, Cyberdog, etc. AppleScript has been around for a very long time and it is still good for many simple tasks you want to do within any app as you can describe each step just as you would have in your mind when controlling the mouse clicks. (If you think python is easy, AppleScript is far more readable.) But the automation power, particular cross apps integration, was hugely improved with Automator, drag and drop, low code automation of macOS. But it came a little too late, just as everyone was switching over to iOS (and iPadOS) as their primary computing device. People who were already seriously using macOS automation were already deeply tangled with AppleScript. So when a third party app Workflow came along and did iOS automation and did it well, Apple was quick to buy it. Further integrated it into the system and renamed it as Shortcut (I guess Workflow sounded too serious). And the rest is history… (Oh, for those who think Apple was bad in killing off the automation market with buying Workflow, the ones who didn’t like them buying up startups like Shazham, Dark Sky, etc, Apple only buys the best and the talent behind it. It’s more honourable than many other acquisition strategies around.)

--

--

--

Experienced technologist, focused on selective combinations of blockchain and AI. I am not a writer, I use Medium like an online notepad to share my thoughts.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A primer into Autonomous Vehicle- From Controls Perspective — Part 1

Functional Test Refactoring: Move

First round of the APIS private sale is now closed!

facebook GTN usage examples(draft)

Library in Python- Pandas

Deploying new features at AutoScout24

12 — Particle Interactions

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Edward Tsang

Edward Tsang

Experienced technologist, focused on selective combinations of blockchain and AI. I am not a writer, I use Medium like an online notepad to share my thoughts.

More from Medium

5 Mac Apps for Awesome Zoom/Google Meet Presentations

Dream Desk Setup: Phase 1

Phase 1 of my desk setup: showing iMac pro on vesa mount and leather desk pad.

Best Shortcuts For The Logitech Master MX3 on MacOS

Image by author. Shot with Sony Alpha 58, 18-55 mm lens. Edited in ON1 Effects 2019.

5 “Daily Use” Mac Apps From Setapp: Part 1

software app icons in a list