Home

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

Incrementing File Versions with Keyboard Maestro

File version management is one of the most important tenets of an efficient, sane post-production workflow. That's why most of the apps we use for our work have built-in tools for "increment and save" or scanning for new versions of an asset. Which makes it pretty odd that I haven't universally quashed this minor annoyance with some simple automation.

Primarily, when I need to version-up a file in Finder, I'm hitting CMD+D, deleting "copy" from the end of the file name and then manually incrementing the version number by typing. What am I, a farmer?

Bound to a hyperkey shortcut, this Keyboard Maestro macro makes it super quick to version up a selection of files in Finder.

Steps

  1. Get the selection of files in Finder
  2. Split the file path into three pieces: everything before the version number, the version number, and everything after the version number
  3. Drop the "v" from the version number. It's cleaner.
  4. Increment the version number with two-digit number padding
  5. Assemble the new file path and name
  6. Copy the original file to its new destination

An Improvement

One thing I don't love about this macro is that it uses rigid two-digit number padding for the version number, no matter the padding on the original file. A factor of the way Keyboard Maestro variables and calculations work.

As much as I disagree with using more than two digits in a file version number, consistency and predictability are far more important to me. So, after a quick chat with the folks over on the Keyboard Maestro forum, I swapped out the "Set Variable to Calculation" action in Step 4 with the following actions, suggested by The Keyboard Maestro himself, Peter N Lewis:

  1. Replace all digits in the version number variable with zeros to create a "padding format"
  2. Build the calculation with KM Variables and our new padding format
  3. Evaluate the calculation

If this change seems overly-complicated and nearly identical to the original version of the macro, it is. The reason we're doing it this way is that the "Set Variable to Calculation" action does not currently support tokens in the "Format" parameter (though Peter says that's fixed in the next version). Building our own calculation formula out of variables and evaluating that formula with a Filter action is functionally the same, but with the extra flexibility we needed. Neat.

iSight Scripting Redux

I was looking through some old photos on my iPhone the other day, reminiscing. Unfortunately, there weren’t a lot of photos from the period of time I was scrolling through. My craving for personal nostalgia was not fully satisfied. Luckily, I remembered another place I might find a few more memories to peruse: my iSight Capture folder in my Dropbox archive.

To spare you the headache of reading that meandering, ill-framed, eight-year-old blog post, here’s the gist of what I built back in 2012.

I set up a bash script and launchd task that used a CLI tool I found called isightcapture to take a photo through my MacBook Pro’s iSight camera every 2 hours, and put them in a Dropbox folder.

I had some grand idea that this would help me locate my laptop if it were ever stolen; giving me photographic clues to its location. Which was incredibly stupid.

But, in setting up this little script, I inadvertently created a sort of photo diary for myself. These incredibly unremarkable images gave me a consistent snapshot of my day-to-day life that, as the months and years passed, became an incredible record of one of the more interesting (to me) periods of my life.

The photos themselves are terrible quality. They’re 640x480 resolution. They’re dark, grainy, and usually framed badly. In some cases, you can barely even see me. But I can see me.

I can see the frustration and immaturity on my face in 2012 — my last year at Intel — before I left to pursue…something I hadn’t worked out yet.

I can see myself doing everything in my power to suppress a sea of self-doubt when I found myself working in the Sandwich Video office for a few weeks in 2013. I was absolutely exhausted driving back and forth between Phoenix and Los Angeles probably a dozen times over the course of a few months. But I was (and still am) so grateful for everything I learned from that experience.

I can see the unexpected enthusiasm on my face as I taught two semesters of post-production finishing and vfx at the film school at Scottsdale Community College; taking over for a professor who had moved away.

There are the backstage photos of those sales and marketing conferences I worked. The ones where we basically didn’t sleep for three days, shooting and editing around the clock.

I see my temporary office setup in the family room of my dad’s house where I lived for a month after moving back to Phoenix from San Jose. Behind me in the photos are the dozens of moving boxes my now-wife and I couldn’t unpack until we found a new place to live. (I really didn’t plan that career/life transition well at all.)

I can see a whole lot in those crappy, automated webcam photos.

May 26, 2016

I don’t remember why, but in May of 2016, my script broke. This is the last photo it took.

I figured I’d find a way to fix it, at some point. Eventually, though, I just gave up and moved the folder of images into my unsynced Dropbox archive folder.

But, looking through those old photos gave me the motivation to give it another shot.

ImageSnap

In the years since my script broke, isightcapture has been abandoned. I found a thread in a forum somewhere mentioning ImageSnap as a potential replacement, and it turned out to be perfect for my needs.

First of all, it’s able to capture the full resolution of my 2020 iMac’s new 1920x1080 FaceTime camera. Still, each photo is only about 250 KB.

Second, it’s much faster than isightcapture. Both apps, when taking a photo, activated the camera’s green “active” light (as they should). But with isightcapture, I was occasionally able to notice the green light in my peripheral vision, look at the camera, and pose for the photo. So far, no matter how quick my reaction time, each photo taken by ImageSnap has been captured before my eyes were able to dart up to the camera. Which is exactly what I want.

I’m genuinely surprised just how fast it is. Especially because the command I’m using to take the photo includes a one second delay to let the camera “warm up”. The hardware (apparently) needs that to avoid occasionally taking an underexposed image.

Here’s the single-line shell script that takes the photo:

/usr/local/bin/imagesnap -d "FaceTime HD Camera (Built-in)" -q -w 1 /Users/dansturm/Dropbox/Photos/iSight_Capture/$(date +"%F—%H-%M-%S").jpg

Automator?

I’m running this script by way of an Automator “Application” because, thanks to macOS Catalina, things that access the camera of my Mac need to throw a macOS system permissions dialogue box so I can grant them explicit access to the hardware. Currently [1], running the command directly inside Keyboard Maestro does not cause the system to prompt for camera permissions, so the command fails.

Not to worry, though. We’ll use Keyboard Maestro to launch the Automator application at the interval of our choosing because it has great trigger options.

Having the app take a photo every two hours was never ideal. A full third of the images are just black because they were taken in the dead of night. And another third were of my empty office chair. Not terribly interesting.

So, this time around, I set the macro to trigger at 10am, 1pm, and 4pm. Three times I can almost guarantee I’ll be sitting at my desk, in front of the camera. And the Keyboard Maestro trigger is flexible enough that, if I decide later to expand the window of time or frequency of images, it’s an easy adjustment.

It’s a little strange how excited I was to get this thing working again. My life is far less unpredictable than it was eight years ago, and it’s likely that I’ll just end up with hundreds of photos that looks exactly the same, featuring nothing of any real interest.

But, you know, that’s exactly what I thought the first time I set it up.


  1. Thanks to Dr. Drang and Peter N Lewis for helping me diagnose this issue. And it sounds like Peter is working on a fix.  ↩

Project Folder Structure and Task Management

For my work, producing videos, it’s incredibly important to keep my files and tasks organized. Managing multiple versions of sequences and shots across thousands of files, hundreds of gigabytes in size, can and will get unwieldy very quickly. The better organized I am from the start, the less likely I’ll be banging my head against my desk in the eleventh hour.

Here’s a brief overview of what I do and how I do it.

The Folder Structure

I’ve been using roughly the same folder structure for my projects for the better part of a decade now. Here’s what it looks like:

For the record, I hate the macOS list view and I never use it while working. I'm only using it here to show you the whole folder structure in one image.

I have high-level folders for the key stages of production: pre-production, production, post-production, and final deliverables. Within each of those folders are subfolders corresponding to specific types of assets that will be gathered or created along the way.

It’s worth mentioning that this folder structure is just the starting point for each of my projects. Not every folder will be used on every project. And, for some projects, many additional folders will be added. For example, a project that includes vfx work (most of them) will have files and folders programmatically created for each vfx shot within the Comp Files, Plates, and Renders folders [1].

Launchbar

To create that folder structure, I run a Keyboard Maestro macro — from Launchbar — that gives me this little pop up:

I give the project a name, hit Return, and the new folder is created in my “Projects” folder in Dropbox.

As an aside, the Launchbar Action I run to activate the Keyboard Maestro macro is called “Planter” because I first began automating my folder structure creation with Brett Terpstra’s great, free application Planter, and I’m a big fan of maintaining muscle memory regardless of whether or not it makes any actual sense [2].

The Things Project

I’m sure you noticed the checkbox on the “New Project” dialog box. Yes, that does what you think it does. If checked (the default), it creates a new project in Things in my “Work” Area with the designated name of the project, and pre-populates it with a standard set of tasks. Again, this is just a starting point. Some tasks may not be required, and many more will likely be added. Regardless, after I hit Return on that dialog box, this is what shows up in Things.

The Tags

There’s one other trick I added to this setup a few years ago that I really like. When navigating through dozens of folders, often with very similar names, it’s easy to get lost. Something that helps me find what I’m looking for more quickly is a Hazel rule that looks through my folder structure and adds a macOS green tag to any folder that is not empty.

This way, after I’ve programmatically created a series of folders that will receive my yet-to-be-rendered vfx shots, I’ll more quickly be able to see which shots have been rendered and which have not.

It doesn’t tell me anything about what’s going on inside that folder, but I find it makes navigation a little quicker and easier, especially with a tired brain.

The Technical Bits

Alright, let’s get to the part with all the images and the scrolling.

The folder creation and the Things project creation are done with two separate Keyboard Maestro macros to attempt to keep things as tidy-ish as possible [3]. The folder creation macro calls the Things macro (if the box is checked) at the end of its steps.

The Folder Creation Macro

Click through to see the whole enchilada.

Click through to see the whole enchilada.

The Things Macro

Click through to see the full image.

Click through to see the full image.

The “New Things Project” macro is built using Things’ JSON based commands, rather than the more limited URL Scheme commands. It’s much more flexible, faster to modify, and is the only way to access certain features like Headings.

If you’re curious, you can see the full code inside that second block of the macro here.

The Hazel Rule

The Hazel rule is fairly simple:

The AppleScript in the second Condition is:

set root_fol to theFile

tell application "Finder"  
    set files_ to count files of entire contents of root_fol  
end tell

if files_ is 0 then  
    return false  
else  
    return true  
end if

I honestly have no recollection of where I found this script on the internet. However, I can tell you with a fair amount of certainty that I did not write it.

This Hazel rule is running on my entire “Projects” folder, so any new folder that’s added will automatically be analyzed and tagged.

All That’s Left to Do Is Everything

So, that’s it. That’s how I begin work on every project. Once a project has a name, it gets a folder and a Things project. Then the actual work can begin. Hooray…


  1. These files and folders are created by the project management tools inside Nuke Studio and that is absolutely a post for another time. Or maybe not because sheesh.  ↩

  2. See also: I use the abbreviation “ch” to launch Safari with Launchbar despite having switched from using Chrome as my primary browser probably 7 years ago. It’s fast and my hands are used to it, so I’m sticking with it.  ↩

  3. lol  ↩

Custom URL Redirects with Rebrandly and Keyboard Maestro

For better or worse, the primary way I share files with clients, other artists, whomever, is sending Dropbox links. With features like password protection and link expiration, Dropbox links are pretty great. But there are two areas where they fail: one, they’re long and ugly, and two, they’re absolute and unable to be redirected to a different file after you’ve shared them.

Yes, in a perfect world I wouldn’t notice problems with my files after I hit send on my emails. Luckily, I can mitigate embarrassing link misfires by creating a custom short URL redirect that I can change later if necessary.

Redirect, Your Honor

I own a couple of short domain names I’ve used to create custom redirects for years. I used to create the redirects directly in the Hover domain dashboard. Which, as you can probably imagine, is not the quickest process.

Recently, however, I was introduced to Rebrandly by my pals Jeff Hodges and Zach Hobesh. Rebrandly is a service for creating and managing custom shortened URL redirects. It connects to your domains quickly and easily, and makes re-branding URLs super easy.

When creating a shortened URL redirect with Rebrandly, the three 1 main components are:

  1. The destination URL
  2. The shortened URL path, which Rebrandly calls a “Slashtag”
  3. A short description of the link, for organizational purposes

Rebrandly’s API documentation is full of example code that made it very easy for me to create a Keyboard Maestro macro that uses their service for shortening my links.

Wrkflw

Creating a rebranded URL with the macro is as simple as:

  1. Place the destination URL on the clipboard.
  2. Press the keyboard shortcut.

A dialogue box will pop up, prefilling the destination URL from the clipboard. There are 2 optional input fields for the Slashtag and the Description. If left blank, Rebrandly will create a random Slashtag that's as short as possible.

Pressing Return will create the shortened URL on Rebrandly, and place it on my clipboard, ready to be pasted into my email, Slack message, or wherever.

I’ve only been using Rebrandly and this Keyboard Maestro macro for a short time, but I’ve been very happy with how fast and easy it makes rebranding URLs.


  1. Technically, the Slashtag and the Description are optional. ↩

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.

Remote Screen Sharing Automation

I’ve always found it fairly easy to manage my multiple Macs with tools like Dropbox, the Mac App Store, and iCloud. But trying to manage Macs that are in different physical locations, on different networks, has really put some of my workflows to the test. There are, it seems, some workflow issues that can’t solved by just putting things in Dropbox. Go figure 1 .

For the past few weeks, I’ve been looking around for ways to “get to” my home iMac from my iMac at work. I quickly found I needed more than just “access to the data” on that computer. I needed to control it via some form of screen sharing.

I tried Screens . It didn’t like my company’s port mapping. Nothing I can really do about that.

Someone in our IT department recommended Royal which, according to my research, is an application that does…something.

In true You’re Doing That Wrong fashion, the solution that had the most success was texting my wife at home and asking her to click “Accept” on the iMessage Screen Sharing request that I was sending from my work computer. But after about a half-dozen requests, I knew I needed a better solution.

Solutioneering

The Screen Sharing tools built into iMessage are great. They’re simple, easy to use, and (miraculously) they just work. I don’t need to open ports on my router or run a private VPN, I just open iMessage, select the person I want to Screen Share with, and click “Ask to Share Screen”.

Given my propensity for making very bad, very unsafe automations, you may be imagining that I just created a Keyboard Maestro macro that would watch for the “Incoming Screen Sharing Request” notification and click “Accept”. But even I realized what an awful idea that would be.

Luckily, there’s another menu item in iMessage, just above the “Ask to Share Screen” item. It’s the “Invite to Share My Screen” option. So, I set about making a tool that I could activate remotely, that would call me from my home iMac and offer to share its screen.

Shortcuts & Hazel

The easiest way to get things up and running was to duplicate a few of the things I’d created for my Open on Which Mac tool. I duplicated the iOS Shortcut I’d use to trigger the whole thing, and the Hazel rule watching for the Shortcut’s input.


  1. Sometimes Dropbox is the issue. But that’s a post for another time. ↩
 
 

The only thing I needed to change in the Shortcut and Hazel rule was to swap “URL” for “ScreenShare” in the filename. So, the Destination Path in the shortcut reads: Applications/Batch/openonmac/Dictionary Value-ScreenShare-Current Date.txt .

While I’m currently only going to use the tool to remote into my home iMac from work, leaving the rest of the Shortcut intact will allow me to more easily 2 add the ability to remote into other computers later.

Keyboard Maestro

Now on to the meat of the thing. We start by using the macOS URL scheme for Messages.app to send a message to my Apple ID. By hard-coding my Apple ID into the macro, there’s no way I can accidentally send the invitation to someone else. Which would be very bad.

By opening the url imessage:myappleid@email.com , KM will open Messages.app and create a new iMessage to my Apple ID. Now, it turns out, it’s not enough to just create a new message with a recipient selected. The Screen Sharing menu items aren’t accessible until you actually send something. So I took this as an opportunity to add a bit of transparency to the process. The macro types out the words “Incoming Connection from Dan’s iMac” and hits Return . In addition to making the Screen Sharing tools accessible, I will get an iMessage (everywhere) letting me know that the Screen Sharing Invitation is imminent and it’s coming from the computer I expected.

Next, the macro opens the “Buddies” menu and selects “Invite to Share My Screen”. Within a few seconds, wherever I may be, and invitation to share the screen of my home iMac appears on my desktop and I can click “Connect”.


  1. With one potentially major hurdle. ↩

That was…surprisingly simple.

Not quite

Since Apple is very good about keeping things safe and secure, the Screen Sharing session activates in “Observing” mode. Which is not terribly helpful. Additionally complicating matters, the only way to approve “Control” of the Screen Sharing session to a remote user is to click on the Screen Sharing menu bar icon that indicates a connection is active.

Initially, I tried to click the menu with Keyboard Maestro’s “Click at Found Image” action, but the menu bar icon flashes when connected and it failed more often than it succeeded. After a bit of googling, some poking around in Activity Monitor, and a brief consultation with Dr. Drang , I discovered I could activate the menu and select “Allow Dan to control my screen” with some basic AppleScript. Which looks like this:

tell application "System Events" to tell process "SSInvitationAgent"
    click menu bar item 1 of menu bar 1
    click menu item 2 of menu 1 of menu bar item 1 of menu bar 1
end tell

Limitations and Improvements

There is one big limitation to this tool. You may have already guessed it. The tool, as it exists here, doesn’t work when the computer is locked. So I resorted to turning off “Require Password” in System Preferences on my home iMac. Which sounds like a huge security risk not worth taking for the benefit it provides but, frankly, if an untrustworthy person is sitting at my desk in my home office, I have bigger problems than whether or not there’s a password on my iMac.

This does, however, preclude me from using this particular solution for the reverse procedure of connecting to my work iMac from home. Turning off my system password definitely isn’t going to fly with our IT department. So, at the moment, this is at best half a solution.

Another thing I’ll probably change in the next iteration of the tool is to remove Hazel from the process entirely. Recently, in the process of debugging a Hazel rule, I recreated it from scratch inside Keyboard Maestro. KM’s ability to watch a folder and act on files that appear inside worked well enough for me to consider migrating more “watch folder” actions over there in the future. Its debugging tools are better, too.

Something else that could use improving is the speed of some of the actions. Currently, depending on how long it takes for me to accept the screen sharing session from my work iMac, the screen sharing menu bar icon may not be available in time for the AppleScript action to find it and grant me “Control” access. My current workaround is to just run the whole process again while I’m in “Observe” mode. It only takes a few second and it works fine.

Speaking of the AppleScript step, there’s also an odd delay of a few seconds between opening the menu bar app and selecting the “Allow Dan to Control” item. In my conversation with Dr. Drang, he pointed me to this post on Stack Overflow which both explained and solved the issue, so that seems like an easy fix for the next version.

By the way, it would seem (to me) that none of this would need to exist if there was some mechanism by which iMessage could tell that the Screen Sharing request was coming from my Apple ID, sent to my Apple ID, and allow me to automatically authenticate those interactions. Hell, prompt me for my iCloud password if you want to keep it safe. Seems like a reasonable request to me, but what do I know. I’m just some idiot with a blog.

Open the Doors

If my penchant for removing incredibly specific, minor inconveniences from my life with overly-complicated, home-grown automation tools wasn't yet fully evident, get ready to be dazzled by the lengths to which I go with this one.

It's winter time here in terrible Phoenix, Arizona, and that means temperatures with highs in the high-70s to low-80s, and lows in the mid-40s. Translated: it's a bit too warm to turn on the heater, and a bit too cool to necessitate air-conditioning.

As a result, over the course of a day, the temperature inside our home ranges from 70F in the morning, to upwards of 78F by late afternoon. Since I work at home and I hate feeling hot [3], I like to keep the front and back doors to the house open in the mornings and evenings, in an effort to cool the house enough to keep the mid-day temperatures inside below 75F.

Generally, that means keeping the doors open in the morning until the temperature outside rises above 70F, and keeping them closed until the temperature drops back down below 70F in the evening.

"I don't see the problem," you say. "Just shout at Siri or your Echo Dot and ask the temperature periodically. Or just look down at your Apple Watch. Or literally any number of other options at your disposal."

Yes, I totally hear you.

Now, take a deep breath because it's going to get weird.

Most weather services use a weather station downtown or at the airport of your city. In my case, those weather stations are 25 miles away and on the other side of a very large mountain. The result being that they're almost always wrong for my neighborhood by about 3 or 4 degrees.

So, I primarily monitor the temperature with a Weather Underground station located less than a half-mile from my home. I keep the WU widget in my Today view on my phone and periodically swipe over, scroll down, and wait for it to update. I love a lot of things about Weather Underground. The speed at which its app refreshes is definitely not one of them. In fact, I usually end up launching the app from the widget in order to make sure it's actually refreshed and not showing me old data. And don't even get me started on its Apple Watch complication. It's tiny and ugly and I hate it.

Are you still reading? Okay, good.

Unrelated to the weather, I've recently begun playing around with Pushover on iOS to send myself custom push notifications based on whatever criteria I deem worthy of a notification. It's super simple to set up and use, has a ton of flexibility, and does exactly what you'd expect it to do. I love it.

I've heard of people using it to alert themselves when a long video render has completed so they can go about their day without needlessly checking the progress bar on their computer. A very cool use case that I will definitely investigate. But, on this morning, I thought to myself, how cool would it be if I could set up Pushover to send me a notification when the temperature at my local WU station goes above / drops below 70F?

To the WU

In addition to being a very cool service, Weather Underground has a nice developer API. You can sign up for a free developer account that will let you to request Current Conditions up to 500 times per day. That's more than enough for what I want to do.

With a simple call of:

curl http://api.wunderground.com/api/DEVELOPERID/conditions/q/AZ/pws:EXAMPLESTATION.json

I get a return like this:

{
  "response": {
  "version":"0.1",
  "termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
  "features": {
  "conditions": 1
  }
    }
  ,    "current_observation": {
        "image": {
        "url":"http://icons.wxug.com/graphics/wu2/logo_130x80.png",
        "title":"Weather Underground",
        "link":"http://www.wunderground.com"
        },
        "display_location": {
        "full":"Phoenix, AZ",
        "city":"Phoenix",
        "state":"AZ",
        "state_name":"Arizona",
        "country":"US",
        "country_iso3166":"US",
        "zip":"XXXXX",
        "magic":"1",
        "wmo":"99999",
        "latitude":"33.XXXXXX",
        "longitude":"-112.XXXXXX",
        "elevation":"373.1"
        },
        "observation_location": {
        "full":"Example Station, Phoenix, Arizona",
        "city":"Example Station, Phoenix",
        "state":"Arizona",
        "country":"US",
        "country_iso3166":"US",
        "latitude":"33.XXXXXXX",
        "longitude":"-112.XXXXXX",
        "elevation":"1214 ft"
        },
        "estimated": {
        },
        "station_id":"EXAMPLESTATION",
        "observation_time":"Last Updated on February 6, 11:46 AM MST",
        "observation_time_rfc822":"Tue, 06 Feb 2018 11:46:53 -0700",
        "observation_epoch":"1517942813",
        "local_time_rfc822":"Tue, 06 Feb 2018 11:47:00 -0700",
        "local_epoch":"1517942820",
        "local_tz_short":"MST",
        "local_tz_long":"America/Phoenix",
        "local_tz_offset":"-0700",
        "weather":"Clear",
        "temperature_string":"72.4 F (22.4 C)",
        "temp_f":72.4,
        "temp_c":22.4,
        "relative_humidity":"21%",
        "wind_string":"From the SE at 1.0 MPH Gusting to 3.0 MPH",
        "wind_dir":"SE",
        "wind_degrees":139,
        "wind_mph":1.0,
        "wind_gust_mph":"3.0",
        "wind_kph":1.6,
        "wind_gust_kph":"4.8",
        "pressure_mb":"1014",
        "pressure_in":"29.95",
        "pressure_trend":"-",
        "dewpoint_string":"30 F (-1 C)",
        "dewpoint_f":30,
        "dewpoint_c":-1,
        "heat_index_string":"NA",
        "heat_index_f":"NA",
        "heat_index_c":"NA",
        "windchill_string":"NA",
        "windchill_f":"NA",
        "windchill_c":"NA",
        "feelslike_string":"72.4 F (22.4 C)",
        "feelslike_f":"72.4",
        "feelslike_c":"22.4",
        "visibility_mi":"10.0",
        "visibility_km":"16.1",
        "solarradiation":"--",
        "UV":"4","precip_1hr_string":"0.00 in ( 0 mm)",
        "precip_1hr_in":"0.00",
        "precip_1hr_metric":" 0",
        "precip_today_string":"0.00 in (0 mm)",
        "precip_today_in":"0.00",
        "precip_today_metric":"0",
        "icon":"clear",
        "icon_url":"http://icons.wxug.com/i/c/k/clear.gif",
        "forecast_url":"http://www.wunderground.com/US/AZ/Phoenix.html",
        "history_url":"http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=EXAMPLESTATION",
        "ob_url":"http://www.wunderground.com/cgi-bin/findweather/getForecast?query=33.XXXXXX,-112.XXXXXX",
        "nowcast":""
    }
}

It's a lot, I know. But it includes everything we would ever want to know about our hyper-local weather station. Including the current temperature, after the value labled temp_f. With a quick REGEX, we can search through this response and pull out just the current temperature in Fahrenheit.

That REGEX looks like this:

(?<="temp_f":)(.*?)(?=,)

The Push

Once we've determined our current temperature is above 70.0F, we'll send ourselves a notification with Pushover by running a command that looks like this:

curl -s \
  --form-string "token=MY_TOKEN" \
  --form-string "user=MY_USERID" \
  --form-string "message=It's above 70F outisde." \
  --form-string "title=Close the Doors" \
  https://api.pushover.net/1/messages.json

Which pops up on my iPhone and Apple Watch looking like this:

The Push Notification from Pushover

The Push Notification from Pushover

Workflow, Assemble

To put all these pieces together, I turn once again to my beloved Keyboard Maestro. Since I'm sending 2 push notifications over the course of the day, I set up 2 macros with different trigger criteria.

Our "Morning" macro doesn't need to start pinging the weather station at 12:01AM, and it won't need to keep checking into the afternoon, so I set it to start, every day, at 6:30AM and stop at 1:00PM. When it stops, the "Evening" macro starts. It begins checking at 1:00PM and stops at Midnight.

While running, each macro requests the current conditions from the weather station every 5 minutes (300 seconds); well under the 500 requests per day we're allowed with our free developer account. Once the temperature reaches 70.0F, the macro ends the loop, sends the push notification, and restarts the next day.

Here are both the Morning and Evening macros:

The Morning Macro in Keyboard Maestro

The Evening Macro in Keyboard Maestro

Why did you do this and why did I just read that?

Truth be told, I'll probably only get 2 or 3 months of usage from this thing each year. Soon, the temperature will be above 70F all day and night and our monthly air-conditioning bill will cost as much as an iPad.

But, until then, this tool is a delightful aide in my quest to stay cool at home, and it was a fun way to explore the Weather Underground and Pushover APIs.

Plus, I haven't posted anything to this blog in a while and I hear that's bad. So.


  1. No, the irony of where I live does not escape me.  ↩

Open Last QuickTime File Macro

Yesterday, Dr. Drang had a nice post about creating a keyboard shortcut for the Open Recent menu item in BBEdit using Keyboard Maestro. I purchased Keyboard Maestro a few months ago and have been meaning to find some time to play with it. I’ve also been meaning to find a way to open the most recently viewed video in QuickTime with a global keyboard shortcut. Let’s skip right to the punchline.

KM_Macro_Cropped.png

Throughout the course of a project, I spend a lot of time referring to the most recent cut of a video alongside notes from the client. Once I know the next shot or note I’m going to address, I close the cut, my notes, and get to it. Since my notes live in nvALT, they disappear and reappear with a quick ⌃Z. Now, no matter what I’m doing, I can quickly summon the video file with a keyboard shortcut as well.

A simple tool that removes way more friction that you’d probably guess. It’s a good thing.