| |

Launch Specific Parts of a Mac App with Stream Deck and Keyboard Maestro

Earlier this week in my Favorites of 2020 post, I bestowed the dubious honor of favorite gadget upon the Elgato Stream Deck. I love automation, and the flexibility of this bad boy to control not only aspects of my computer, but aspects of my home, is fantastic.

Well I recently picked up the Stream Deck XL and have a few extra buttons to play with now. One thing I thought would be interesting is to launch a specific note in Bear Notes. Turns out you can totally do that! Here’s how.

The Key: x-callback-urls

The key to all of this is x-callback-urls. Here’s a quick definition from the website:

The goal of the x-callback-url specification is to provide a standardized means for iOS developers to expose and document the methods they make available to other apps.

Basically, they started as a way for iOS apps to talk to each other. But the x-callback-url grew into much more as app developers started adding it to Mac apps as well.

You can think of the x-callback-url as a “link” to a part of an app. Much like a website URL will take you a specific webpage in the browser, x-callback-urls take you to specific “pages” within an app. Here’s an example of an x-callback-url in Bear Notes:


You can see it specifically mentions the app (Bear), then has an action (open-note), along with a unique identifier for the specific note. Naturally this URL will behave differently for different Bear users, but for me, it opens a note called “Swipe Copy.”

With that, let’s take a look at everything we need to get this done!

The Ingredients

First thing’s first: you need to make sure the app you want to use supports x-callback-url. You can find a non-comprehensive list here, but it’s best to check the documentation for the specific app you want to use.

Aside from that we’ll need:

We Don’t Need Safari!

In my first iteration of this, I figured I would need Safari. You’ve likely seen a little pop up in Safari that will ask if a URL should be opened in an app:

A popup in Safari asking if I want to open an x-callback-url in Bear.

In Keyboard Maestro, you can pass a URL to Safari, then simulate a press of the Enter/Return key. This is actually how I end Zoom calls so quickly! I thought I’d need to do something similar here. But it turns out, that’s to a little shell command, I don’t!

The Shell Command

Scouring the Keyboard Maestro forum, I came across this post, which showed me the following shell command:

open -a <specific app> <url>

Brilliant! As long as I know the app name and the URL (more on that in a minute), I could just execute a shell command with Keyboard Maestro. I took a stab in the dark and assumed the app name for Bear Notes was bear. I was right! So my full command looks like this:

open -a bear bear://x-callback-url/open-note?id=6D6FECF6-0819-46B9-B2D1-CD30FCF84EDC-585-0000BE248FEB99AF

Finding the x-callback-url in Bear

This will vary from app to app, but to find the x-callback-url in Bear:

  1. Select the note you want to reference
  2. In the top right of the note, click the 3 dots icon
  3. Click “Copy Link to Note”

Here’s a GIF of these steps in action:

an animate gift showing the steps (above this image) to get an x-callback-url in Bear Notes

Now it’s time to put that command into Keyboard Maestro.

Creating the Keyboard Maestro Action

Before actually creation the action, you’ll want to designate the button on your Stream Deck.

Configure Stream Deck Button

  1. Open the Stream Deck app
  2. From the right-hand panel of actions, find the Keyboard Maestro action (you may need to install it)
  3. Drag the action to the button you want to use.

That’s it for now. The button ID will be important. Here’s what mine looks like:

Keyboard Maestro action on Stream Deck

Creating the Action

To make things easier, you can download the macro! Just note you’ll need to change the Stream Deck button and shell script.

  1. Press the right-most + button to create a new macro
  2. Name the Macro
  3. From the “Triggered by” list, select, “USB Device Key Trigger”
  4. Click inside the box that shows up below
  5. Press the designated button on your Stream Deck
  6. Under “Will execute the following actions,” add “Execute Shell Script” (doing a search for shell will help you find it quickly.
  7. Paste in your shell command!

Here’s (approximately) what it should look like:

Screenshot of Keyboard Maestro Macro described above.

Happy Automating!

I hope this helps you. I have TONS of ideas for what I could do with this. Looks like I really need to dig into David Sparks’ Keyboard Maestro Field Guide now!

DO you have any cool Keyboard Maestro macros? Let me know in the comments!

Leave a Reply

Your email address will not be published. Required fields are marked *