CMD-D Logo

CMD-D | Masters of Automation with Sal Soghoian

Sal Soghoian Allison
Sal Soghoian

This week Steve and I attended, and I spoke at the CMD-D Conference, created by Sal Soghoian. Sal was responsible for all Automation at Apple for many years. His team managed AppleScript, Automaton, and Terminal. Pretty much all the coolest stuff at Apple.

I have to tell you I was pretty intimidated about speaking at this conference. I’ll get into that a little bit more in a bit but I want to tell you about the conference and then about my presentation. You know, better story telling that way.

Scripting Bootcamp

Steve and I signed up for not just the conference itself, but also a one-day AppleScript Boot Camp taught by a guy I hadn’t met before, named Ray Robertson. Ray started what he calls “Scripting Events” in 1998 and has been teaching people how to automate tasks with AppleScript ever since. His passion is manipulating text for publishing.

The class was really interesting. For the morning sessions he started really slow, explained simple things like how to set variables, the common AppleScript commands, and all about objects. He taught us about the Script Editor, and how to view the Libraries of applications that are scriptable, and then the dictionaries for those libraries.

Allison Ray Robertson CMD D
Ray Robertson

I think the coolest thing about the way he taught us was that he gave us a download of a ton of example scripts, all well named and numbered so they’d stay neatly in order and we could pop them open and follow along. It was fun to be in a lab environment and mess things up on our own computers and see how they broke. The afternoon accelerated to about four times the pace, so Steve and I did struggle a bit to keep up. It was great for awareness of what AppleScript could do, but it wasn’t a follow-along-and-play-with-it type of lab in the afternoon.

I found AppleScript to be very pleasing in its syntax. It’s not quite natural language but it’s definitely human readable.

One of my favorite parts of the class was when Ray asked the audience, “What do you call curly braces?” It was like he set up a softball for me: I hollered out “Squirrely Brackets!” That’s what I started calling them in Programming By Stealth a long time ago and I’ve done it often enough that from time to time you’ll actually hear Bart call them that. Ray loved it and decided that he’s calling them that from now on. Ray is SO my people.

I knew that AppleScript had been around for a very long time (it came out in 1993 as part of System 7.1.1) but what I didn’t realize is that it’s not really in active development. You might think that’s a bad thing, but how much time do we spend complaining about apps, like Skype, where every time you open them the interface has changed? Or how Apple keeps adding features to the OS when it would be swell if they’d take some time to fix the stuff they’ve already created.

Ray said that the way to approach AppleScript is to search on line for someone who has solved the same problem (or close to it) and use their script. That was fascinating to me, because that’s exactly what Dorothy does when she works on AppleScript for me! I thought maybe she was just lazy or something, but it turns out that’s what everyone does. I think one of the reasons you can do this is because AppleScript has been around so long and changes so slowly. You can do a search and find a script from 2003, and there’s a good chance it will still work.

One thing thing that really surprised me about AppleScript is that you can use it to actually draw graphics. At the break, Ray launched an AppleScript which opened Adobe InDesign and drew a working clock on the screen! Now I know I’ll never do that, and it does require an app to be scriptable, but still, it stood out that the sky is the limit on what you can do with these tools.

Overall I really enjoyed taking Ray’s course because it showed me what’s possible. It also tickled me to notice similar things in AppleScript to what we’ve been learning about JavaScript in Programming By Stealth.

If you’re interesting in checking out Ray’s work, his site is at automatedworkflows.com and you can follow him on Twitter at scriptsmatter.

The Actual CMD-D Conference

Steve with Pixel Core fancy cameras
Steve with Pixel Corps Cameras

The next day was the actual CMD-D conference. All of the talks were recorded on video by none other than Alex Lindsay and his Pixel Corps team. If you’re unfamiliar with Alex, he’s a frequent host on MacBreak Weekly, and his Pixel Corps company has done video work for the Obama administration and the Rwandan Government! So I expect that when the videos are published, they’ll be AMAZING. The Pixel Corps guys enlisted Steve to help with plugging in the presenters’ Macs to the A/V system, putting mics on them and being the time keeper, and he really enjoyed giving them a hand.

The conference schedule listed all of the sessions, but they didn’t show who was doing which talk. It turns out that Sal was doing MOST of them, which really surprised me.

Before I tell you about the things he showed us, I want to back up and talk just a smidge about my preparation for my talk. When we attended the awesome Macstock in Chicago a last month, Mike Schmitz created a presentation that appeared to be a live demo, but it wasn’t. I didn’t even realize it wasn’t live until Steve pointed it out to me. I asked Mike how he did it.

He recorded a screencast of his Mac while going through the steps he wanted to demonstrate on stage. Then he chopped the video up into short little videos and plopped each one onto individual Keynote slides. In this way, he could hit a slide and let it play and talk as long or as short as he wanted, and then advance to the next slide when he was ready. It was super smooth and gave the impression that he was simply flawless at doing live demos.

I thought this was a brilliant and slick idea, so I figured I’d blow the audience away by doing my slides the same way. But guess what? Every single person who did a presentation had done exactly this! Thank goodness I saw Mike’s presentation at Macstock or I’d have been the only one risking it by doing things live!

But to say my presentation was as slick as the others would be a vast overstatement. Sal’s presentations in particular were the most beautifully orchestrated and fluid slides that I’ve ever witnessed in my life. I know, he worked for Apple for years and he did this for a living, but still, it was really amazing to watch.

Sal started the conference by demonstrating his vision of the future of computing. He demonstrated how he sees us being able to simply tell our computers what to do and they will do our bidding. Pretty much like Scotty was used to in The Voyage Home. Sal invoked dictation on his Mac and told it to do all kinds of crazy things. He stressed that everything he was doing was 100% doable today (no tricks in his demo) but that they’re just not stitched together in an easy way in macOS yet.

The one that caught my eye that would solve a real problem for me had to do with Photos. It is an incredibly tedious process to add titles to images in Apple Photos. In his demo of the future, he orally instructed his Mac to launch Photos, selected a handful, and then said, “assist me in adding titles”. A window came up offering to let him enter titles and each time he hit enter, the next image was ready to be entitled. I loved it! I found the entire set of scripts and installation instructions on one of his automation websites, dictationcommands.com. I’m going to give it a go and see if I can get it to work.

Here’s another example of something he can do. He can open a Numbers spreadsheet, and invoke a script that takes the data and puts it into a graph inside a Keynote presentation. I know, right? It was crazy.

Then he showed us how you can run AppleScript from the command line! If you type osascript -e it will enter a console where you can type and execute AppleScript. Seriously nerdy and fun. You can even change it to interactive JavaScript by typing osascript -l JavaScript! He didn’t tell us how to get out of that console, but Jon Pugh sitting behind me volunteered the answer – you hit control-D. By the way, Jon Pugh isn’t any run of the mill nerd. He worked for Apple too, and he’s the one who put the Clipboard commands into AppleScript! I’m telling you, the air was pretty thin at this conference. I think he liked me because I was using the green screen theme called Homebrew for my Terminal window.

Sal eventually moved on to talk about JavaScript automation on the Mac. Of course since I’m practically a Jedi master at JavaScript because of Programming By Stealth (note tone of sarcasm), my little ears perked up. He explained that it’s called JavaScript for Automation, abbreviated JXA.

This is when things got seriously nuts. Sal now works for the Omni Group, and has figured out how to allow you to run JavaScript inside the Omni applications OmniGraffle and OmniFocus for both the Mac and iOS. Think about what that means – you’re running scripts to control an application that’s approved in the App Stores!

I cannot begin to explain how this works but here’s an example of what he did. He opened the diagramming program OmniGraffle. He drew a rectangle on the screen. In the menubar was a little command prompt as a button. He pushed that, and it opened a JavaScript console inside OmniGraffle. It immediately showed the JavaScript code to draw that square on the screen. It showed the coordinates and that it had a black stroke. He then started editing it, first by changing rectangle to circle. As soon as he changed the code, the square turned into a circle in the app.

Then he started adding and changing attributes. Soon it had a red stroke and a yellow center. Before we knew it he was clicking on code and suddenly these super complex, and beautiful graphics started showing up on screen. He switched over to the iPad and repeated the same process so we’d believe it was possible on both platforms.

But wait, there’s more. Before he was done, he had created a custom url that was the JavaScript code that when clicked would create the graphics over in OmniGraffle. It was crazy. I can’t say I would ever do any of this, but still it was amazing to see what could be done. That was his objective and he certainly achieved that goal.

My talk

Let’s move on to my presentation. Imagine that Mozart had just played a piano concerto on stage, and it’s your turn to get up and play chopsticks. That’s how I felt as I awaited my turn to talk. You guys know I thrive on public speaking, right? Obviously, I’m a podcaster! But can you even imagine how nervous I was after seeing Sal produce magic before our very eyes?

A couple of things happened that made me have the courage to get up in front of that crowd. Jason Snell was there, and while I’ve been on podcasts like Clockwise with him before, we’d never met in person. He is as sweet and funny and all around wonderful as you would ever hope. I told Jason that I was really intimidated about speaking after Sal.

Allison Jason Snell
Jason Snell

He said, “You have to remember something, Allison. There’s Sal … and then there’s EVERYONE ELSE.” I felt so much better after he said that!

Then I found out that David Sparks of Mac Power Users was speaking directly after Sal and I would be after David. Now David is no hack and is a wonderful speaker with a fantastic self-deprecating style, but at least we’re in the same league! We chatted before he went up and he acknowledged that he was taking the bullet for me.

And finally, I talked a bit to Ray Robertson (the guy that taught the AppleScript class) right before I went up. I told him how happy it had made me when he actually said “squirrely brackets” in his class. I told him something else I have done to Bart in Programming By Stealth. Whenever he shows me a command and I’m not sure if something is a variable to which I am allowed to assign any name, or if maybe it’s a sacred word I can’t change, I ask him, “can I call that boogers?”

At first it was just for a laugh but now Bart regularly uses examples where his variable name is boogers, just to be sure to make it clear to me that I can name that thing myself. I told Ray about this and he loved it, but then gave me a challenge. Since he had used squirrely brackets in his talk, he wanted me to use boogers in my talk! Now remember, I’m terrified if I’m going to look like an idiot up there.

Allison presenting at CMD D taken by Adam Tow dev of Hazel
Allison On Stage – photo by Adam Tow

In part of my talk I showed a script written by Econ Technologies, the people who wrote Chronosync. They made me a script to mount my Drobos so I could be sure they were there before attempting a backup between them. I had the script on screen in my talk but I had to change the username and password for the demo, so I said, “I changed the password here, because I didn’t want you to know my real password was boogers!” No one seemed to react to it but I got a thumbs up from Ray, so I figure we’re friends for life now.

I think my talk went off well. It was entitled “Code-Free Automation”. I started by explaining that while I’m a “reasonably bright girl”, (a guy at IBM actually called my friend Linda that once!) I showed a picture of my diploma from UCLA with my Masters in Mechanical Engineering. But I then explained that my last formal programming class was Fortran IV with watfiv in 1982! On that page I showed a picture of some actual programming I did for my Masters degree.

Next I explained that while I don’t have the programming experience, I do have an innate desire to optimize things in my life that I hate to do. I put in a picture of the silverware tray for my dishwasher with all the spoons near each other, the knives together and the forks together. I explained that my dishwasher silverware tray has little slots in it so you have to place every piece of silverware carefully into its own slot.

I started thinking, since you can’t just grab a bunch of them to put them in, why not place them in categories, which means when you take them back out, you can grab a bunch and just throw them into the silverware drawer. The audience went wild. Well, I might have made them say they thought that was amazing.

From there I explained that I do a lot of little things to automate what I do to create the podcast. I started with the baby steps, like naming my podcast audio files consistently and how I use Hazel to watch my podcast folder and when the files are 2 weeks old, move them off to my Drobo. I got in a good one for David Sparks here. I explained that the ONLY way to learn Hazel was to get David’s Video Field Guide from macsparky.com/… and watch it. I then splatted across the screen “Not a paid endorsement!” in giant red letters. Got a laugh from the crowd and a huge grin from David. I’m not sure it’s related but later on he told me that he loved my presentation.

Remember when I was explaining 1Password at Macstock and suddenly found out that the lead developer for 1Password was in the audience and how unnerving it was? Well, it happened again; the developer of Hazel was in the room! I really needed that kind of pressure…

The big finale of my presentation was supposed to be me showing off my favorite AppleScript. The problem to be solved is that there is no keystroke to put a modern MacBook Pro to sleep. You can sleep the displays with a keystroke, but not the Mac. So I use an AppleScript that simply says:

tell Application "Finder" to sleep

My plan was to run the script, my Mac would go to sleep, and I would yell “TADA!” and throw my hands in the air to thunderous applause. But I had done the one thing you NEVER do, and that is change something at the last minute before you go on stage.

When David was setting his MacBook Pro up on stage, the Pixel Corps guys had to do a bunch of shenanigans to get the real slides on the two big screens, and his presenter notes on the display facing him in front of the stage. I wanted the same setup, and there were zero minutes planned between our presentations. David suggested to save time fiddling around, I should just put my presentation on his Mac. I thought that was a grand idea, so I used my slick USB-C thumb drive my buddy Ron bought me to move my presentation over. What I didn’t remember was that my sleep script was on my Mac, but not his!

I realized this to my horror on stage as I was about to complete my presentation. Being quick on my feet, I suggested that we do some LIVE programming! I rolled up my sleeves (literally) and then opened the AppleScript Editor, and typed in my one line script. I made a typo, forgetting the quotes around “Finder”, and Sal’s wife Naomi yelled out, “you forgot the quotes!” I fixed the typo, hit the run button and my Mac went to sleep.

I’m not joking when I say that the audience loved it. Here’s the funny part. Much later in the day, Ray got up to do a presentation and he pointed something out. He said, “So Allison’s presentation was titled ‘Code-Free AutomatIon’ and she’s the only person who did live coding on stage!”

The conference was from 9 in the morning to 10 at night, with the last hour being a podcast recording by Jason Snell with me, Sal, Shelly Brisbin, David and John Welch as the panel. It will be coming out as part of Monday the 14th of August’s Upgrade podcast at relay.fm/upgrade.

Steve and I both had an absolutely wonderful time at the show. On top of the swell people I already talked about, it was great fun to meet Scott Dye, Brent Schmitz, and Tom Wickland, all of whom recognized me by voice from the various podcasts I’m on. They were all really fun, and nice and nerdy. We also shared an AirBnB with the awesome Shelly Brisbin which was great fun.

I sure hope CMD-D happens again and I get to attend again.

2 thoughts on “CMD-D | Masters of Automation with Sal Soghoian

  1. has - August 15, 2017

    “This is when things got seriously nuts. Sal now works for the Omni Group, and has figured out how to allow you to run JavaScript inside the Omni applications OmniGraffle and OmniFocus for both the Mac and iOS. Think about what that means – you’re running scripts to control an application that’s approved in the App Stores!”

    Sorry, but Sal did NOT figure this out. Embeddable JavaScript on macOS and iOS was 100% the WebKit/JavaScriptCore team’s work, and was announced back at WWDC 2013 as a programmer-friendly alternative to OSA (“AppleScript”) support:

    https://developer.apple.com/videos/play/wwdc2013/615/

    JavaScriptCoreCore itself has been around for over a decade, being used in WebKit/Safari, but only with an obscure C API that was fiddly to use. The OS X 10.9 update added a nice high-level Cocoa API plus a really easy way to expose an app’s own internal ObjC APIs to it. While still a poor alternative to well-designed, well-implemented, well-documented OSA support, with the whole OSA platform being in decline for the last decade one could argue that having even second-rate automation support is still far better than none at all.

    Internal politicking between WWDCs 13 and 14 must have put the kibosh on the JavaScriptCore’s teams own plans, however, and JSCore was handed over to Sal’s Mac Automation team instead, who decided to repackage it as an OSA language, “JavaScript for Automation”, with the same support for “application scripting” (Apple event IPC, which lets it control other apps such as Finder and iTunes) and “attachability” (which lets apps trigger user-supplied OSA scripts, e.g. Folder Actions and Mail rules). A HUGE potential win for Mac Automation: with JavaScript already being one of the most popular and fastest growing languages in the world thanks to its global web browser presence, and now making major inroads into server and desktop markets thanks to open-source community-led projects like Node.js, such timing could not have been better!

    JXA’s design and implementation was rushed and flawed, meaning some tasks that worked perfectly in AS broke in JXA; however, the Automation’s team fatal mistake was once it was released in 10.10 they did absolutely _nothing_ afterwards to market, evangelize, educate, or support it, or even let existing JavaScripters know it was there. As a result, JXA completely failed to build a new market for itself. Even the few JS users who did stumble on JXA often ended up back in AppleScript, having grow frustrated at trying to make JXA work in absence of bug fixes, documentation, or community support.

    By comparison, Node.js now has well over THREE MILLION users, massive documentation, library, tool, and community support, and is rapidly growing by something like a half-million users every year!

    Even if JXA had won just 1% of that 3,000,000 in its first year, it would have created 30,000 excited, enthusiastic, brand new Mac Automation users; more than enough for Apple to see the potential and reinvest in OSA as their premier *OS Automation product. It was—not to put it too finely—an utterly incompetent New Product launch; a mistake that didn’t just cost Sal his team and his job, but also almost certainly has cost all of us Users the Mac Automation we know and love now, as Apple and App vendors wind down OSA support in the coming years.

  2. podfeet - August 16, 2017

    has – thanks for the education. I had no idea.

Leave a Reply

Your email address will not be published.

Scroll to top