Home

You’re Doing That Wrong is a journal of various successes and failures by Dan Sturm.

Open on Which Mac for Mac

The names of these things are getting pretty bad. But the Open on Which Mac iOS Shortcut I created is still one of my favorite automations I’ve created. I use it every day to send links from my phone to whichever computer suits the context for the content I’m saving for later.

But I don't only discover interesting links on my iPhone. Occasionally I’ll come across something while I’m at work and want to send it to my home computer so it’s open, waiting for me when I sit down.

The flexibility of having built the OOWM service on Plaintext files, Dropbox, and Hazel means I don't need to modify any of the existing automation steps in order to add a new source to the mix. All I need to do is create a fast method for saving a url to a specifically-named text file in a specific location, and the Hazel rule will see it and act on it, just as it does with links from my iPhone.

Keyboard Maestro, Duh

The Keyboard Maestro macro follows the same structure as the iOS Shortcut. First, it grabs the url from the active Safari tab. Then it presents the user with a list of computers to choose from for the destination of the link. Once a computer name has been selected, it uses a dictionary of computer name short-codes to create the specific text file name, then saves the file to the OOWM folder in Dropbox.

The filename — since it's too long to read in the screenshot — is:

%Dictionary[WhichComp,%Variable%compName%]%-URL-%ICUDateTime%yyyy-MM-dd%.txt

It really is that simple. And since this is running on a Mac, it’s much faster than its iOS counterpart.

And with that, one of my favorite automations just got more favoriter.

"Open on Which Mac" Shortcut v3

Two whole days ago, I posted an updated version of my Open on Mac Shortcut. When I post my hacky automation tools online, the absolute best possible response I can hope for is being corrected by someone much smarter than I am.

Like when I posted v1 of the shortcut and Jason Snell pointed out that I had inadvertently created a way for anyone with access to my Dropbox account to execute arbitrary code on my computer. Which is a pretty bad thing, to be honest. Luckily, he modified the shortcut and posted a much better version on Six Colors.

When I posted v2 of my shortcut on Tuesday, in the caption for the (very long) shortcut image, I wrote:

These If statements are terrible and ugly and there’s got to be a better way to do this, but I don't know what it is.

A few hours later, I received a lovely Twitter DM from Dr. Drang with the answer to my question.

To avoid the nested if statements, set up a dictionary with the Mac names as the keys and the file name prefixes as the values. Then assemble the file name by looking up from that dictionary after the Choose step.

— Dr. Drang, Famous Internet Snowman

 
 

The file name in the Destination Path of the Save File action is "Dictionary Value-URL-Current Date.txt. The shortcut is now much shorter, easier to understand, faster, and generally less bad.

Thanks, Doc.

"Open on Which Mac" Shortcut

A few weeks ago, I started a new job. Along with that job came a new iMac and Touch Bar MacBook Pro. Having doubled the number of computers in my life, I quickly found that my frequently-used Open on Mac iOS Shortcut was not working as expected.

While at work, attempting to open a webpage on my iMac would result in...nothing. When I got home, I found the pages open and waiting for me on my personal iMac.

Prior to the newly acquired computers, I had never given much thought to why webpages opened on my iMac rather than my MacBook Pro. I spent 98% of my time on the iMac and, since it was doing what I wanted it to do, there was no reason to ask why. I mostly assumed it was because the MacBook Pro was asleep and the iMac is always awake.

As it turns out, the real reason webpages always opened on my personal iMac is because it has the fastest internet connection (a wired fiber connection) and would therefore download the Dropbox file containing the URL before any other computers had the chance. Hazel would then do its thing, trash the file, and that was that.

It had become necessary to modify my iOS Shortcut, allowing me to specify on which computer I wanted to open the webpage. To accomplish that goal, I added a "Choose from List" action to the shortcut where I could pick which computer to use. Then, I added short prefixes to the filename that represented each computer.

 
 

The original text file containing the page URL was called "URL-Current Date.txt". The new file names are:

  • The Touch Bar: tbr-URL-Current Date.txt
  • The New iMac: niM-URL-Current Date.txt
  • My MacBook Pro: mbp-URL-Current Date.txt
  • My iMac: diM-URL-Current Date.txt

Add a couple of "If" statements to the shortcut and we're about done. Here's what the new, much longer shortcut looks like.

 

These If statements are terrible and ugly and there’s got to be a better way to do this, but I don't know what it is.

 

After finishing the shortcut, all that was left to do was add the prefixes to the name search field in the Hazel rules running on each computer and call it done.

P.S. Thank you, again, to Jason Snell for fixing my very unsafe, poorly conceived version 1.0.

Open Website on Mac Workflow

Update – 2018-01-05

Over at Six Colors, Jason Snell has created a much smarter, safer version of this whole iOS to Mac automation idea.

His version, smartly, builds the shell script on the Mac side — only receiving keywords and URLs from the iOS device — as opposed to my version which is set up to just immediately run whatever text file shell script happens to pop up in my Dropbox folder. A less-than-ideal setup should someone else acquire access to that Dropbox folder. Go check it out.


This may be one of the laziest automation tools I've ever created, but I solves an annoyance that's been bugging me for a long while now.

Often times I'll be looking at a website on my iPhone and I'll want to switch over to viewing it on my Mac. "That's why Apple created Handoff," you say. Yes, well, personally I find Handoff to be slow, unreliable, and only half of the solution.

I'm looking at a website on my phone. I want to press a button on my phone and have that website open in Safari on my Mac. I don't want to wait for a dock icon to appear on my Mac. I don't want to try to click on it, quickly, before it disappears. I don't want to look through a list of open iCloud tabs in Safari on my Mac.

I want to tap and have it open.

What I Did

I used everyone's favorite iOS automation tool Workflow.app to create an Application Extension Workflow that grabs the current URL and saves it to a date/time stamped text file in a specific Dropbox folder. It looks like this:

 
 

Then, I set up Hazel on my Mac to monitor that folder and, when it sees a new file, run the file with Bash, then throw it in the Trash. Here's what that looks like:

Overly complicated? Probably.

Lazy? Almost certainly.

Does it do the job I wanted it to do? Absolutely.

It takes about 6 seconds from tapping on the Workflow in Safari on my phone to having an open page in Safari on my Mac. That's not exactly fast, but it's no slower than using Handoff. It's also far more reliable and requires less interaction from me.

And, let's not forget, this will work from any distance. There's no Bluetooth range limit like Handoff. Wherever you are, as long as you've got an internet connection, you can use this Workflow to have a website open and waiting for you on your Mac when you get home.