Revisor 3 Plugin for Premiere

Back in 2022, when Sandwich partnered with Supasupply to build the original Revisor plugin for Adobe Premiere, the versioning tools were meant to be the first of several conform tools I wanted to build. For a number of uninteresting reasons, the project never went beyond the initial development phase before being abandoned by the developer1.

It always frustrated me that I wasn’t able to take over the project and continue development myself. In addition to all the features I wanted to add, there was an occasional bug in some fragile AppleScript within the plugin. The script simulated clicking the File menu but sometimes failed to release the mouse-down state. The only way to break the command and resume working was to force quit Premiere. After a while, some of our people just stopped using Revisor because it was more of a hassle than it was worth.

I tried several times over the years to decipher Adobe’s inscrutable ExtendScript CEP and UXP plugin architectures in the hopes of resurrecting the project. It did not go well.

Eventually, AI coding tools became good enough to assist with that work and I was able to make the smallest amount of progress on a new version. I fixed the AppleScript mouse-down bug, which got us using the plugin again. But, once again, development stalled.

When I fixed the mouse-down menu bug, I also stripped all AppleScript out of the plugin. It was just too buggy and unreliable. Unfortunately, the Option+click functionality that would stack a new version of a clip on a higher video track was also built with AppleScript, basically running a copy-and-paste operation. While we could live without that particular feature, the clip-stacking functionality was essential for the next round of features I wanted to add.

I tried recreating the stacking function with CEP ExtendScript. It would read the clip name in the timeline, go get a new copy of the clip from the bin, place it on the timeline at the correct spot, read the effects on the source clip, create fresh copies of the effects on the new clip, then set the parameter values to match the original. A lot of extra work that was probably more buggy than the AppleScript it replaced. And, importantly, it was not possible to create a Lumetri Color effect with a custom LUT path already selected. Something we use on every project.

Eventually, I tried the UXP plugin framework and found it had a createCloneTrackItemAction() function that would perfectly duplicate a timeline clip, effects intact. What UXP couldn’t do was swap a clip’s source media, either to version up the render or pull in new media for a conform operation.

I had two half solutions and neither of them got me where I wanted to go.

The Bridge

Recently, ChatGPT and I took one more crack at this problem. I laid out the issues. This feature works well in CEP but it’s missing a crucial piece that exists in UXP. UXP can’t handle the file operations, but it has a much more reliable clone function. I asked the robot, what’s our best path forward here?

It replied, rather obviously, “Why don’t you just use the parts of CEP that work and the parts of UXP that work and bridge them together behind the scenes?”

Turns out, yes, you can do that.

In a couple of hours, I had a version of Revisor that was faster, more reliable, and included all my fancy new conform tools.

Revisor 3

Revisor 3

Version Management

The version management tools remain unchanged. I can still select one or many clips and jump to the minimum, previous, next, or maximum version of that render.

Quick Batch Trimming

The Trim Clips section is fairly self-explanatory. Select any number of clips, enter a number of frames to trim, and click whichever trim function you want.

The “Close” option is probably used most often. It trims the frames and closes the gaps between all trimmed clips. If I’m manually conforming a bunch of log plates to start an online edit, I can drop all my clips on the timeline and quickly remove the typical eight-frame handles.

The other trim options remove the frames and align the newly trimmed clips to the Left, Center, or Right sides of the clip’s previous bounds.

Apply LUTs

We work with cameras from a handful of manufacturers and apply each camera’s default Rec. 709 LUT to our log plates in the timeline. I was finally able to figure out how to apply a Lumetri Color effect to clips and load a custom LUT into it, making it much faster to get from Log to camera color.

Conform Tools

The conform tools are the main event in Revisor 3. Previously, I’d use the Build Track tools in Nuke Studio to create timelines of each asset type, then send XMLs to Premiere for import. Now, the editor can grab any asset from any shot with a single click.

The buttons extract the shot name from the selected clip — typically a log plate, but any asset with a shot number will work — and, combined with a user-defined relative path, they will find and conform the highest version of a shot asset. Select a log plate, click comp, it will stack the latest comp. Done.

The “Grade” button is a little bit of extra magic on top. We often end up with multiple graded assets per shot. A graded plate, a graded paint render, a graded comp, etc. The Grade button notices which asset you’ve got selected and pulls in the graded version of that particular asset. Select the log plate, click grade, it stacks the graded plate. Select the comp layer, click grade, it stacks the graded comp.

Custom Config Files

I knew if I was going to make a plugin with logic this complicated, it would need to be flexible and easy to modify. If our folder structure changes, or a new project uses a differently named asset that doesn’t match the patterns of these buttons, I need to be able to customize the behavior quickly.

To that end, all of the conform buttons are loaded dynamically from a JSON config file that lives in the ~/.revisor folder. If I need a new conform type, I can add it to the config, reload the config inside Premiere (without restarting the app), and immediately get a new button.

So, what’s customizable:

The version number matching pattern is adjustable if you want to restrict the number padding size of your version numbers. I prefer 2-digit number padding, but some vendors deliver 3-digit version numbers, so my version number pattern is “two or more”: "versionPattern": "_v##+".

Probably the most important customizable parameter is the method by which we locate a clip’s “shot folder”. You can define the regex for extracting the shot number from the clip name and how the plugin traverses the folder structure to find the matching folder name. Since all our shot assets live within the shot folder, we use nearestAncestorNamed to walk up the folder path until we find the folder that matches the shot name. The other option is projectRootRelative, which allows you to define the path to the location of the shot folders.

"shot": {
    "from": "filename",
    "regex": "^[A-Za-z]{4}_(?:[0-9]+_)?[0-9]{4}(?=_)",
    "rootStrategy": "nearestAncestorNamed",
    "examples": [
        {
            "filename": "pldv_3020_log_plate_v01.mov",
            "expectedShot": "pldv_3020"
        },
        {
            "filename": "pldv_110_3020_comp_v006.mov",
            "expectedShot": "pldv_110_3020"
        }
    ]
},

The Conforms section of the config is where we build the buttons that are loaded by the plugin:

"conforms": [
    {
        "id": "comp",
        "label": "Comp",
        "searchPath": "{shotRoot}/renders/comp",
        "filenamePattern": "{shot}_comp{version}.{extension}",
        "extensions": ["mov", "mxf", "mp4"]
    },
    {
        "id": "paint",
        "label": "Paint",
        "searchPath": "{shotRoot}/renders/comp",
        "filenamePattern": "{shot}_paint{version}.{extension}",
        "extensions": ["mov", "mxf", "mp4"]
    },

The Grade button matches the source and destination variants with a source pattern and destination filename pattern:

"id": "graded",
"label": "Grade",
"variants": {
    "graded_comp": {
        "sourceFilenamePattern": "{shot}_comp{version}.{extension}",
        "searchPath": "{shotRoot}/renders/comp",
        "filenamePattern": "{shot}_comp{version}_graded.{extension}",
        "extensions": ["mov", "mxf", "mp4"]
    },

Lastly, the LUTs dropdown is populated with paths to our .cube files.

"luts": [
    {
        "id": "apple_log_rec709",
        "label": "Apple Log",
        "path": "/Volumes/sandwich/assets/LUTs/Apple/AppleLogToRec709-v1.0.cube"
    },
    {
        "id": "arri_logc4_rec709",
        "label": "ARRI LogC4",
        "path": "/Volumes/sandwich/assets/LUTs/Arri/ARRI_LogC4-to-Gamma24_Rec709-D65_v1-33.cube"
    },

And, of course, we can create as many configs as we like and switch between them as needed.

Multiple config files

I don’t know how we ever got anything done before we had these tools, but I’m glad we don’t have to live in that world anymore.

Footnotes

  1. The original plugin is still available, free of charge, on the Supasupply website. ↩

Annotation Manager for Preview

During the process of making a video, I annotate a lot of images. For our outsourced paint and roto work, or for notes on a work-in-progress VFX shot, I'll draw on a video frame to illustrate what work needs to be completed.

Over the years, I've built some pretty handy tools to streamline this work. It typically starts from my timeline in Nuke Studio. As I scrub, when I see a shot that needs work, I hit a keyboard shortcut which does the following:

  1. Exports the frame I'm parked on, with burned-in slate information included
  2. Names the file with the name of the shot and the frame number
  3. Puts the file in a dated folder within the outbox of the project folder
  4. Opens the image in Preview
  5. Activates Preview's annotation tools

Not bad.

It's usually one or two dozen shots that I end up annotating per video. But recently, we had a project where that number hit triple digits. That project put a huge spotlight on some remaining friction in this process.

Oftentimes, there are multiple shots that need at least some of the same work done. These five shots need that thing removed. Three of them also need this other thing fixed, which is in these other seven shots, too. Just two of them need this thing over here. It's a lot of that.

Can I just annotate one image and write out a list of what needs to be done to which shot? No. Exacting clarity saves time, money, and sanity — none of which I typically have in surplus. So, I annotate a frame for every shot that needs work.

But it’s not that bad. I can copy and paste annotations from one image to another when there’s duplicate work [1] . This means I often have dozens of images open at once and use CMD+~ to move between them [2] .

Even better, I'm a responsible nerd with a clipboard manager (LaunchBar), so reusing lots of annotations is no big deal, right? This brings us to the actual problem.

Which one of these is the text label and circles for the dirt on the left wall? Which one is for the dust on the laptop screen? Even if I did remember, as soon as I select and paste it, the order of the clipboard history is now different. Good luck playing the worst game of Memory ever.

What I needed was a clipboard manager that could copy groups of annotation objects from Preview, keep them in order, and allow me to add a label so I know what they are.

Usually, Python is my weapon of choice for automation. I've made plenty of little GUI tools with Qt, and I probably could have done the same here. But this time, I decided I'd try to make a Real Mac App, because why not.

This is what I came up with:

The app is always on top of my other windows for quick access. I can create and store as many annotations as I'd like. There are keyboard shortcuts for copying and pasting.

Each slot can hold any number of Preview annotation objects. Whatever annotations are selected when I hit "save" are stored as a single group, but once pasted into a new image, they're all still individually selectable and movable. The annotation slot can also be updated later, if needed.

If there's anything about the app that bugs me, it's that it has to activate Preview in order to run the copy command, so there's a little flicker as it switches to Preview and back. Aside from that, though, this little utility has saved me so much time and headache.

That being said, making this as a Mac app was not especially simple or enjoyable, so I'm not sure I'll be making many more.


  1. That is, as long as I haven’t closed the image yet because Preview will flatten all the annotations and they will no longer be selectable. Drives me nuts.  ↩

  2. By the way, did you know that sometimes Preview just reverses the order you’re moving through files with CMD+~ and to keep going in the order you started with you have to switch to CMD+Shift+~? That’s a fun little quirk.  ↩

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.
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  ↩

The One With Dropbox and the Symlink

I’ll be honest, this post is more for me than it is for you. I’m writing it so the next time I’m setting up a new Mac, I’ll know exactly where to find the solution to one of Dropbox’s most puzzling idiosyncrasies.

Dropbox users, like myself, who have both a personal Dropbox account and a business account, have the ability to link those two accounts and sync both folders to a single computer [1]. When you do that, your folder previously-named Dropbox is renamed to Dropbox (Personal) and your business account is named Your Company Dropbox. Which…seems silly to me, but okay, I guess.

Aside from being an unattractive folder name, Dropbox (Personal) is pretty terrible for automation and general usability. Spaces? Parentheses? It’s like they’re trying to break all my scripts and customizations.

And before you ask, no, you can’t just rename the folder back to Dropbox. Once you install the Dropbox app, the computer belongs to them, you’re just allowed to use it. Them’s the rules.

Now, when I first linked my two Dropbox accounts, I could have gone through all my Keyboard Maestro macros and shell scripts and done some find & replace work to make everything work again. But as fun as that sounds, I opted for the lazy route: creating a symlink called Dropbox that pointed to Dropbox (Personal) so all my stuff would just work again.

If I were smarter and better versed in the ways of the Terminal, I wouldn’t have to look this sort of stuff up when I needed to do it. Alas, this isn’t the sort of thing I need to do more than once every handful of years, and this knowledge will leave my brain the second I close that Terminal window.

I’m Writing It Down to Remember It Later

Here’s what I did:

  1. Make a symlink to “Dropbox (Personal)” and place it on the Desktop, thusly:
    ln -s "/Users/dansturm/Dropbox (Personal)" /Users/dansturm/Desktop

  2. Next rename the symlink on the Desktop to just “Dropbox”.

  3. Move the symlink into your Home directory, next to the ugly folder.

  4. Hide the symlink so you can forget you ever had to do this whole stupid thing:
    chflags -h hidden /Users/dansturm/Dropbox

And now your scripts, automations, file paths, etc, will function just as they did before Dropbox decided to get cutesy with the name of the folder where you keep everything you’ve ever created on your Mac for the past 10+ years.


  1. You can link one personal account to one business account and that’s it. You can’t have two personal accounts or two business accounts or three of any combination. Kinda makes you think this whole linking thing was a bit of an afterthought.  ↩

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 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.