Start work right with this one-click app and playlist launcher

By

applescript
Writing this AppleScript is as easy as writing your shopping list.
Photo: David Ballew/Unsplash

Every morning when I sit at my Mac to start writing, I open the same apps and start the same iTunes playlist. This repetitive, tedious task is what computers are supposed to do for us, so I figured I’d make my Mac open up those apps, and start that music playing, all without me having to do anything.

That dream was quickly quashed — the Mac isn’t quite able to read my mind yet. So I settled for the next best thing: An AppleScript that I can leave in the Dock, and then click once to open everything. The best part is, it’s absurdly easy to make your own.

An AppleScript to open lots of things at once

I do most of my research and organization on my iPad, but when I begin writing, these days I switch to my old Mac. And every time I do, I launch Ulysses, Things and Slack. I also play the same playlist in iTunes, to get me in the mood. Making an AppleScript to do all of these things is trivial.

AppleScript at its simplest.
AppleScript at its simplest.
Photo: Cult of Mac

Here it is in text, if you want to copy and modify it:

tell application "iTunes"

play playlist named “work”

tell application "Finder"

launch application "UlyssesMac"

launch application "Things3"

launch application "Slack"

end tell

end tell

To play along, open up the Script Editor app on your Mac (inside the Applications > Utilities folder) and create a new editor window by typing ⌘N. Paste in the above script, then hit the little hammer icon in the window toolbar. This compiles the script, and will show you an error message if anything is wrong.

Then, save the script in a sensible place on your Mac. The default location used to be ~/Library/Scripts, where ~ refers to your home folder. In practice, though, anywhere will do. Even the desktop, if you’re some kind of animal.

To edit the script, just change the application names and the playlist name. Sometimes, the app name isn’t what you think it is. In my example, Slack is Slack, but Ulysses is actually called UlyssesMac. If you write the wrong name, when you try to compile the script, the Script Editor app will open up the dictionary window, which will list all the apps on your Mac. Just find the one you want in the list, and click it. The correct name will be inserted into your script.

How to run your AppleScript

Now you need a way to run the script. If you use an application launcher like Launchbar, then all you need to do is run it from there. This is what I do. I hit my ⌘-Space hotkey to invoke Launchbar, type “work,” and then hit return. That’s it. All three apps pop open, and the music starts playing. If iTunes isn’t already open, it launches.

If you prefer to put the script in the Dock, you will need to save it as an application first. If you just put the script itself in the Dock, clicking it will open it in the Script Editor. So, back in the Script Editor app, with your script still open, go to File > Export… in the menu bar, and save your script as an application, using the File Format pop-up menu:

Choose 'Application' from the File Tormat menu in the export dialog box.
Choose “Application” from the File Format menu in the export dialog box.
Photo: Cult of Mac

Save this in the same place as your script, for convenience, then drag it into your Mac’s Dock. Now, a single click will run the script. The downside of doing it this way is that you’ll have to resave this application every time you make a change to the script.

This isn’t limited to launching apps and playlists, of course, but if you’ve never used AppleScript, this is a great place to begin. Have fun.

Newsletters

Daily round-ups or a weekly refresher, straight from Cult of Mac to your inbox.

  • The Weekender

    The week's best Apple news, reviews and how-tos from Cult of Mac, every Saturday morning. Our readers say: "Thank you guys for always posting cool stuff" -- Vaughn Nevins. "Very informative" -- Kenly Xavier.