Obsidian Menu Automation

Better Touch Tool now includes (beta) support for the Elgato Stream Deck, and I’ve been investigating how I can make good use of this functionality. During my experimentation, I came across something rather curious about trying to work with my notes app of choice, Obsidian. Menu automation appeared to be a stumbling block - at least at first.

Obsidian: Menu Items, the Command Palette and Keyboard Shortcuts

Obsidian is a fantastically capable application and one for which I am immensely grateful for the cross-platform aspects. As someone who works across multiple platforms, I’m always happiest when I get to use an application across many of them. As well as being cross-platform, Obsidian is flexible in how you can access its functionality.

The command palette in the application gives access to almost anything you might want to do within a few keystrokes, and I use it a lot! Obsidian also allows you to set keyboard shortcuts for pretty much anything you like. In fact if you find there is something you cannot add a keyboard shortcut too, the chances are one of the “hotkey” community plugins will enable it for you.

However, there are also a few useful items hidden among the Mac menu bar items too. Many of these are available in the command palette and so can be assigned keyboard shortcuts.

While I use lots of keyboard shortcuts, I find it difficult to remember what they all are, which is why I like solutions like the Stream Deck, and the Mac Touch Bar. In fact, my Touch Bar has very much been my on the go Stream Deck replacement, so I am not looking forward to the time I have to give that up. I also don’t like assigning random keyboard shortcuts where it can be avoided. I already have enough and each time I add a new one, I risk conflicting with another one.

As a result, if I am not intending to use a keyboard shortcut semi-regularly, I would rather find a non-keyboard shortcut key option when it comes to automating.

Triggering the Obsidian Sidebar with Better Touch Tool

Obsidian has a left sidebar that can be toggled open and closed by the Mac menu.

I figured that this would be easy enough to add a button to my Stream Deck to activate and toggle the sidebar to show/hide. Since I was using Better Touch Tool already, I figured I would just add a Menubar-Item action and set it to trigger the menu.

But, this didn’t work. When I pressed the button on my Stream Deck, nothing happened.

Just to rule out anything being strange with the naming, I switched the menu details to (6);(1), but the same result, nothing happened.

I tried a similar menu automation in another application, and that worked fine. Something was certainly amiss.

Triggering the Obsidian Sidebar with Keyboard Maestro

The majority of my automations triggered from my Stream Deck are in fact Keyboard Maestro macros. A great deal of my automation is centralised to Keyboard Maestro, and Keyboard Maestro also has support for working with menus. I therefore created a simple macro to trigger the sidebar toggling, and changed my Better Touch Tool Stream deck button trigger to trigger the Keyboard Maestro macro via a URL call.

The result was identical to that experienced using Better Touch Tool alone. I tried triggering the macro directly from within Keyboard Maestro, the application being specified as Obsidian. But, nothing happened.

I added a Play System Beep action to the macro and when run, it sounded, so it certainly seemed to be something to do with Obsidian.

Triggering the Obsidian Sidebar with a URL

Obviously, interacting with the Mac menus was getting me nowhere. To avoid “hotkey hell”, I decided to explore the options for working with Obsidian itself. Being an electron app, the only option open other than clicks and key presses to interact with the user interface is interaction via URL.

By default, Obsidian’s URL scheme is limited. Not in a bad way, it just does not have a wide range of functionality.

There is a community plugin that enables a much wider range of options. It is called Obsidian Advanced URI. This was *exactly* what I needed.

As I mentioned above, the command palette in Obsidian lets you do just about anything. That includes toggling the left sidebar, and the Obsidian Advanced URI plugin lets you execute commands from the command palette via a URL.

I went through my Obsidian vaults on my Mac, and added the plugin to any vault that did not already have it. I then switched out the Keyboard Maestro macro URL to the Obsidian URL.

The URL I used was this:

obsidian://advanced-uri?commandid=app%253Atoggle-left-sidebar

But, you might be wondering exactly how I got it. Well, the Obsidian Advanced URI plugin also includes some commands of its own to help you get the URL of something you might want to do.

With my obsidian_demo vault open, I first triggered the command to copy the URL for another command.

I next chose the option to not tie this to a specific file.

Lastly, I selected the command I wanted to trigger.

The resulting URL the plugin generated and placed on the clipboard was this:

obsidian://advanced-uri?vault=obsidian_demo&commandid=app%253Atoggle-left-sidebar

However, I didn’t want this tied to a particular vault, so I removed the vault parameter to just leave the base command, and that’s how I ended up with the URL shown above in Better Touch Tool.

Summary

Using this last approach, the Stream Deck button works seamlessly, and the response feels instant. The Obsidian Advanced URI plugin is now a base install plugin for any Obsidian vault I create, and it will likely form the backbone of further external Obsidian app automations I create in the future.

If you are at all interested in automating Obsidian, and especially if you want to use a Stream Deck to trigger some of those automations, I would strongly recommend that you consider installing the plugin too.

Author: Stephen Millard
Tags: | obsidian | better touch tool | keyboard maestro | stream deck |

Buy me a coffeeBuy me a coffee



Related posts that you may also like to read