(Updated 2023/12/13) 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 very technical and you don’t need to know how to code, 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:
- Autoloading Websites Each Morning (Mac)
- Autoloading Apps Each Morning (iOS)
- Automate your “Going Home” ETA routine (iOS)
- Keyboard Shortcuts
- Use NFC to trigger iOS Shortcuts
- Use Automator to watch out for Folder Actions
- Use Accessibility Feature to enable Back Tap as extra “buttons” on your iPhone
- File Sharing and Access
- Automate changing/selecting macOS audio input/output
- Automate Screenshot Processing on iOS *New*
- Other tips and tricks
1. 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.
- 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.)
- Type the following (Copy and Paste), without the quotes: “env EDITOR=nano crontab -e”
- 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
2. 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”.)
3. 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:
- 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.
- 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. 🙂
- 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.
- 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. 🙂
Shortcuts app can’t share an Automation script directly, 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. In fact, I recommend doing the logic in a separate shortcut then trigger it using Automation.
A few tips:
- 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.
- 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.
- You can use similar ideas in these scripts to semi-automate these inter-device messaging and timer setting.
- 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.
4. 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.
⌥⇧8 Degree Symbol °, not a shortcut as such, but good to learn a few more key combos to type faster, I also use ⌥Yfor ¥; ⌥⇧2 for €; ⌥3 for £.
A quick reminder:
⌥ Option
⌃ Control
⇧ Shift
⌘ Command
5. 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.
6. 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.
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.
7. 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.)
8. File Sharing and Access
Might be a little confusing as to why file sharing is part of automation. It’s easy to think of files are just random zeroes and ones stored here and there. But start seeing it as the key digital assets you own. We are talking about automation of our tasks digitally and many of them will be dealing with digital assets. A photo is an asset, you created it with your camera, which is just a tool. You can replace the tool often, but you can’t easily replace the asset you have created, so take good care of them. (That’s probably why people still don’t understand crypto because many just look at it as some system for transaction records.)
Cloud is great for online storage, but I don’t put everything on the cloud. I have nearly 300GB of Photos, 100GB of Music 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 my every digital bits. Also, there are horror stories online of accounts having issues and all files and gmail disappeared and no recovery or compensation. 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 a little 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 an official iOS client, so I ruled it out, still great for server P2P sync.
Get to know how to use these tools well. And it will help you will always having the files you need wherever you are and be able to share with anyone you want.
https://www.resilio.com/individuals/ — Resilio Sync
https://cryptomator.org/ — Cryptomator
9. Automate changing/selecting macOS (Ventura tested) audio input/output
For some odd reason, my macOS system will change the microphone input volume of my speakerphone after system sleep randomly. And it annoys me that I have to go into System Settings > Sound and fiddle with the input volume just a little. The fix is to automate this using the following app on github and then script the startup every day.
GitHub – deweller/switchaudio-osx: Change the audio source for Mac OS X from the command line.
A command-line utility to switch the audio source on Mac OS X. This utility switches the audio source for Mac OS X. You…github.com
Set Input and Output Sound Devices in MacOS Ventura
Set Sound Ventura.kmmacros (4.5 KB) (* Author: Ike Nassi ([email protected]) 2022-11-02 Written because 13.0 (Ventura)…forum.keyboardmaestro.com
10. Automate Screenshot Processing on iOS *New*
My online bank doesn’t have API that I can write code to get my current balance. And I often have to open the bank app, check the balance, then do some calculation with the bank balance. I do this like 30 times a day. So I needed to automate it.
So here is the flow, write a Shortcut to take a screenshot, it will then extract all text in the screenshot, do some text matching for numbers, do some calculations, put the calculated value back to clipboard, delete the screenshot and then open the app I have to use the calculated value with. As it is a frequently used script, I mapped it to the triple back tap, so I just need to open the banking app, login, when I can see the balance, do the triple click and it automate the calculation. I am just going to share my shortcut link here. You can also enable the delete without confirmation option so your temporary screenshot will get deleted without warning each time (Settings -> Shortcuts -> Advanced -> Allow deleteting without confirmation). You have to fiddle with the Match pattern, the RegExp reference can be found here.
11. Other Tips and Tricks
- Date Format https://unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns My preferred way is yyyyMMdd HH:mm, easy to customise it. Common to mix up MM for months and mm for minutes.
- You can use Shortcuts in conjunction with other shared services to interact with other users. Shared Calendar if you want to trigger alarms/alerts on different devices with a few users. Shared Reminders to have a shared checklist. Shared Notes or Notes Folder to automate some shared information. A quick reminder is that Shortcuts can only used for creating new notes or appending to existing notes, you can’t remove a note or delete previous text, but you can remove calendar events and shared reminders. (Another annoying part is that Notes can only append text to the end, not at the front, only way around it is to create a new note with the text in the order you want.)
- If you need to trigger other Shortcuts with other users, you can use some semi-automatic way via iMessage or email. Check the example above for the go-home-routine. These will prompt you when you receive the right formatted trigger message, but this might not be very stable particular when you are using the phone at the time of receiving the messages.
- Don’t write complex logic inside iOS Shortcuts Automation. Write is as a shortcut then use Automation to “Run Shortcut”. In this way, you can share the code with others easily and let them decide on how to automate the running of it.
- Learn about Regular Expression, very useful when you need to find and replace text in your shortcuts. Use this reference documentation here if needed. https://unicode-org.github.io/icu/userguide/strings/regexp.html
I also keep a list of Mac apps which I use, most of them are free apps. Check it out here.
The Top 20 Mac Apps for Making Life Easier
Just keeping a list of apps I (and my dev team) use on Mac/iOS regularly. Most of them are free apps. Might be a little…eplt.medium.com
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.
Other References:
- https://support.apple.com/en-gb/guide/automator/welcome/mac
- Apple Automator with AppleScript Bible 1st Edition, Kindle Edition
- AppleScript 1st Edition by Mark Conway Munro
- URL Scheme — Learn about these to get direct access to specific features of the apps you use
- Alipay URI Scheme — Good for automating some tasks with the daily points collection.
- https://jiejingku.net/13789.html — One of the most “complex” script for automating daily reward collection of many Chinese apps. It uses icloud drive to store the settings, etc. Very smart.
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.)
Leave a Comment