Triggering events on macOS from iOS

With my updated Mac mini 1, I've started getting back into looking at automation ideas for my home setup. A recent Mac Power Users podcast hit close to home for me because it was a great discussion by David and Stephen on the recently updated Mac mini. David and Stephen were talking about a possible automation idea that would allow David to automate turning on/off macOS services that would enable David to connect to his Mac using Screenson his iPad.2

Triggering Outline

David's idea motivated me to look at creating a framework that could be easily duplicated to trigger events on my Mac mini from my iPad or iPhone. I wanted a process that would do the following:

  • From iOS, create a trigger mechanism that can use Dropbox or iCloud.
  • From macOS, monitor for the trigger mechanism and initiate an action on the Mac without user interaction.
  • From iOS get confirmation that the trigger action successfully completed.

To set up this automation process, you'll need a few tools on both your iOS device and macOS computer:

From there you'll need to select your cloud platform of choice: Dropbox or iCloud. All the directions listed below will be for Dropbox. The alterations to make the workflow fit for iCloud are pretty minor.

Create trigger file on Dropbox

The initiator to this process is using an action in Shortcuts to create the trigger file in Dropbox. I don't care what the file name is, so I asked one of my kids for a made up word.3

So when this shortcut is run, it will create an empty text file in Dropbox in the designated folder.

Watching for trigger file on macOS

Now that the trigger file has been created, a Hazel rule needs to monitor the folder for the file. Hazel will do 2 things in this example:

  • Remove the trigger file
  • Run an AppleScript.

Applescript FTW

The last piece is what action should take place if the trigger file is found. In my working example I wanted to know what the external IP address is for my Mac mini via an email message. This is the AppleScript embedded in the Hazel rule in the previous step.

The script has 2 parts:

  1. Determine the external IP address of the Mac.
  2. Email the information to a preset email address.

Once triggered, the email will look like this:

Side note: I'll probably update the script to send a Message instead of an email since that's even more universal for my normal workflows.

Wrapping it all up

The main upside of using Shortcuts app, instead of other automation tools, is the Shortcut actions are automatically sync'd across all my iOS devices. So now with one button I can get the current external IP address of my Mac mini from any of my iOS devices.

  1. I still think it should be "Mini" vs "mini" 

  2. Fastforward to about 58 min into the episode.  

  3. I'm thinking of using my kids as my password generator from now on.  

Previous posts:

  1. Rationalizing my choices for the Mac Mini

    My recent internal deliberations on what to replace my ailing computer setup has led to quite a few false starts on what I put into my virtual shopping cart. As much as I wanted to love the new MacBook Air, the power and flexibility didn't hit enough cylinders to trigger …

  2. Pondering next computer purchase

    Like a lot of Apple fans, I watched the presentation by Tim Cook and Co. last Tuesday about Apple’s new fall product releases. The order that Apple presented their new products was absolute genius.

    • Mac Book Air: Here’s a gorgeous new mobile device.
    • Mac Mini: Here’s a …
  3. Limiting the voices of my Monkey brain

    For a while I've been training in Tae Kwon Do.1 Most of the training has been the physical side of martial arts and self defense. I had the opportunity recently to participate in a different kind of self defense course called 'Violence Dynamics'. The concept of the course is …

  4. Using Keyboard Maestro to drive Marked 2

    My writing tools are varied based on where/how I'm writing - laptop vs iPad vs iPhone. But the final review process almost always ends up on my Mac in Marked 2. Marked 2 is a peculiarly wonderful app in that it doesn't directly create anything. Marked 2 is just for …

  5. Maximo's Built In Sharing Service

    One of the challenges in my Maximo environment is an efficient way to keep and store 'living documents'. A lot of us have Dropbox, Box, SharePoint, etc., but most of those services are either restricted from widespread access (Dropbox) or have a versioning system (SharePoint) that can make keeping living …